Skip to content

Commit cdcaa4e

Browse files
update 3/readme
1 parent 6a85581 commit cdcaa4e

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

3_CustomerLoanAccount/README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
1. [Execution at the command line](#execution-at-the-command-line)
66
2. [`Customer` Class](#customer-class)
77
3. [`CustomerLoanAccount` Class](#customerloanaccount-class)
8+
4. [Requirements](#requirements)
89

910
#### Execution at the command line
1011

@@ -152,4 +153,50 @@ public class CustomerLoanAccount extends Object {
152153
}
153154
}
154155
}
156+
```
157+
158+
#### Requirements
159+
160+
Enhance the Loan Accounts Hierarchy from project `2_LoanAccountHierarchy` by adding a `Customer` class with the following properties and methods:
161+
* property `firstName` the customer's first name (`String`)
162+
* property `lastName` the customer's last name (`String`)
163+
* property `SSN` the customer's SSN (`String`)
164+
* property `loanAccounts` an array list of loan accounts (`ArrayList<LoanAccount>`)
165+
* a constructor that accepts `firstName`, `lastName`, and `SSN` as parameters
166+
* getters for `firstName`, `lastName`, and `SSN`
167+
* method `addLoanAccount(LoanAccount account)` adds a loan to the array list of loans for this customer
168+
* method `printMonthlyReport()` prints all the information for all the accounts of this `Customer` and utilizes the `toString()` method of the corresponding loan class
169+
170+
Use the following code in the main function to test the classes:
171+
172+
```java
173+
CarLoan carLoan1 = new CarLoan(25_000.00, 4.9, 72, "IRQ3458977");
174+
Address propertyAddress1 = new Address("321 Main Street", "State College", "PA", "16801");
175+
PrimaryMortgage propertyLoan1 = new PrimaryMortgage(250_000.00, 3.75, 360, 35.12, propertyAddress1);
176+
UnsecuredLoan unsecuredLoan = new UnsecuredLoan(5_000.00, 10.75, 48);
177+
178+
CarLoan carLoan2 = new CarLoan(12_000.00, 5.0, 60, "NXK6767876");
179+
Address propertyAddress2 = new Address("783 Maple Lane", "State College", "PA", "16801");
180+
PrimaryMortgage propertyLoan2 = new PrimaryMortgage(375_000.00, 2.50, 360, 53.12, propertyAddress2);
181+
182+
Customer customerA = new Customer("Tony", "Stark", "111-22-3333");
183+
Customer customerB = new Customer( "Gal", "Gadot", "444-55-6666");
184+
185+
customerA.addLoanAccount(carLoan1);
186+
customerA.addLoanAccount(propertyLoan1);
187+
customerA.addLoanAccount(unsecuredLoan);
188+
189+
customerB.addLoanAccount(carLoan2);
190+
customerB.addLoanAccount(propertyLoan2);
191+
192+
// add the customers to an arraylist of customers
193+
ArrayList<Customer> customers = new ArrayList<>();
194+
customers.add(customerA);
195+
customers.add(customerB);
196+
197+
// print the loan information for each customer polymorhically
198+
System.out.println("Monthly Report of Customers by Loan Account");
199+
for (Customer customer : customers) {
200+
customer.printMonthlyReport();
201+
}
155202
```

0 commit comments

Comments
 (0)