|
13 | 13 | 10. [`UnsecuredLoan` Class](#unsecuredloan-class)
|
14 | 14 | 11. [`UnsecuredLoanTest` Class](#unsecuredloantest-class)
|
15 | 15 | 12. [`LoanAccountHierarchy` Class](#loanaccounthierarchy-class)
|
| 16 | +13. [Instructions](#instructions) |
16 | 17 |
|
17 | 18 | #### Execution at the command line
|
18 | 19 |
|
@@ -342,4 +343,68 @@ public class LoanAccountHierarchy extends Object {
|
342 | 343 | System.out.printf("%s%n%n%s%n%n%s%n", carLoan, propertyLoan, unsecuredLoan);
|
343 | 344 | }
|
344 | 345 | }
|
| 346 | +``` |
| 347 | + |
| 348 | +#### Instructions |
| 349 | + |
| 350 | +Create a Loan Account Hierarchy consisting of the following classes: |
| 351 | +* `LoanAccount` |
| 352 | +* `CarLoan` |
| 353 | +* `PrimaryMortgage` |
| 354 | +* `UnsecuredLoan` |
| 355 | +* `Address` |
| 356 | + |
| 357 | +Each class should be in it's own .java file. |
| 358 | + |
| 359 | +The `LoanAccount` class consists of the following properties: |
| 360 | +* `principal` the original amount of the loan |
| 361 | +* `annualInterestRate` the annual interest rate for the loan (it is not static as each loan can have it's own interest rate) |
| 362 | +* `months` the number of months in the term of the loan (i.e. the length of the loan) |
| 363 | + |
| 364 | +and the following methods: |
| 365 | +* a constructor that takes the three properties as parameters |
| 366 | +* `calculateMonthlyPayment()` takes no parameters and calculates the monthly payment using the same formula as project `1_LoanAccount` |
| 367 | +* getters for the three property variables |
| 368 | +* `toString()` displays the information about the `principal`, `annualInterestRate`, and `months` |
| 369 | + |
| 370 | +The `CarLoan` class which is a subclass of the `LoanAccount` class and consists of the following property: |
| 371 | +* `vehicleVIN` the VIN number of the car, as a string |
| 372 | + |
| 373 | +and the following methods: |
| 374 | +* constructor that accepts the three parameters of the LoanAccount class and the vehicleVIN |
| 375 | +* `toString()` displays information about the VIN number |
| 376 | + |
| 377 | +The `PrimaryMortgage` class which is a subclass of `LoanAccount` and consists of the following properties: |
| 378 | +* `PMIMonthlyAmount` the amount of the Primary Mortgage Insurance which is required for all mortgages where the down payment is not at least 20% of the home value |
| 379 | +* `Address` the address of the real estate and is an object of the `Address` class |
| 380 | + |
| 381 | +and the following methods: |
| 382 | +* constructor that accepts the three parameters of the LoanAccount class, the PMIMonthlyAmount, and the Address object containing the address |
| 383 | +* `toString()` displays information about the PMIMonthlyAmount and Address |
| 384 | + |
| 385 | +The `UnsecuredLoan` class which is a subclass of `LoanAccount` and has no additional properties and has the following methods: |
| 386 | +* constructor that accepts the three parameters of the `LoanAccount` |
| 387 | +* `toString()` displays that it is an Unsecured Loan |
| 388 | + |
| 389 | +The `Address` class which consists of the following properties: |
| 390 | +* `street` the house number and the street name |
| 391 | +* `city` |
| 392 | +* `state` |
| 393 | +* `zipcode` |
| 394 | + |
| 395 | +and the following methods: |
| 396 | +* constructor which accepts the values for the four properties as parameters |
| 397 | +* getters for each property |
| 398 | +* `toString()` displays the address information |
| 399 | + |
| 400 | +Code in the subclasses should call methods in the super classes whenever possible to reduce the amount of code in the subclasses and utilize the code already developed in the super classes. Use the following code in the main function to test the classes: |
| 401 | + |
| 402 | +```java |
| 403 | +// Create three different loan objects, one of each type. |
| 404 | +CarLoan carLoan = new CarLoan(25_000.00, 4.25, 72, "IRQ3458977"); |
| 405 | +Address propertyAddress = new Address("321 Main Street", "State College", "PA", "16801"); |
| 406 | +PrimaryMortgage propertyLoan = new PrimaryMortgage(250_000.00, 3.1, 360, 35.12, propertyAddress); |
| 407 | +UnsecuredLoan unsecuredLoan = new UnsecuredLoan(5_000.00, 10.75, 48); |
| 408 | +//Print out the load information for each loan using the toString() method. |
| 409 | +System.out.format("%n%s%s%s%n", carLoan, propertyLoan, unsecuredLoan); |
345 | 410 | ```
|
0 commit comments