|
5 | 5 | 1. [Execution at the command line](#execution-at-the-command-line)
|
6 | 6 | 2. [`Customer` Class](#customer-class)
|
7 | 7 | 3. [`CustomerLoanAccount` Class](#customerloanaccount-class)
|
| 8 | +4. [Requirements](#requirements) |
8 | 9 |
|
9 | 10 | #### Execution at the command line
|
10 | 11 |
|
@@ -152,4 +153,50 @@ public class CustomerLoanAccount extends Object {
|
152 | 153 | }
|
153 | 154 | }
|
154 | 155 | }
|
| 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 | +} |
155 | 202 | ```
|
0 commit comments