12A

Implement a subclass of Product called Book. Book has a String instance variable, author, in addition to description and price.

Provide the instance variable and methods

Provide Javadoc. Use@Override for the overridden getDescription method

For the draft, start the Book class as a subclass of Product. Provide the new instance variable, author. Write the constructor that takes description, price, and author, in that order. Be sure to initialize all the instance variables. Implement sameAuthor as a stub complete with Javadoc. Remember that if a stub's return type is boolean, return false.

12A draft:
12A final:

12B

You are given a BankAccount class. You are to write two subclasses: FeeBasedAccount and TimeDepositAccount

BankAccount:

This class is provided for you. It is different from earlier versions in that it requires a minimum balance of 5000. There is a $15.00 fee for any month where the ending balance is below the minimum balance. There is an endOfMonth method to handle end of month processing. Its subclasses will handle end of month processing differently.

FeeBasedAccount:

This account is a subclass of BankAccount. It has no minimum balance, but there is a charges for every transaction after a certain number of free transactions. At the current time, the number of free transactions is 3 and the charge is a $2.00 for every transaction after that amount. Both deposits and withdrawals are transactions. There is no charge to get the balance. The fees are subtracted during end of moth processing. Define and use constants. You did something similar to this in one of the labs.

TimeDepositAccount:

This account is a subclass of BankAccount. In this type of account, you promise to leave the money in the bank for a specified about of time. There is a penalty for early withdrawal. The constructor takes an additional parameter: the amount of time you must leave the money in the bank in months as an int. (This time is called the time to maturity). The current the interest rate is 1.1% per year compounded monthly. The penalty for early withdrawal is 20% of the amount withdrawn. The penalty is subtracted immediately, but interest is added during end of month processing. Provide a method getTimeToMaturity that returns the amount of time the money must be left on deposit. This is provided in the constructor and does not change. There is no penalty for depositing money. Define and use constants.

 

For the draft, implement FeeBasedAccount

12B draft:
12B final:

12C

In this problem you are dealing with a hierarchy of inheritance. You will use the BankAccount and FeeBasedAccount from 12b along with the SavingsAccount class you will write.

SavingsAccount:

This is a subclass of BankAccount. The owner of the account can deposit or withdraw money at any point. The account earns 0.9% interest annually compounded monthly. Interest is paid on the ending balance during end of month processing. Use a constant for annual interest rate.

Write an application called AccountRunner. (It will have a main method) Do the following.

Create a BankAccount array that can hold 3 item. Add these items

Loop through the array:

Now from only the FeeBasedAccount, withdraw another 100

Finally in a second loop

For the draft, implement SavingsAccount

This AccountRunner is an example of polymorphism and dynamic binding. Each time through the loop, you have a BankAccount reference. The first time through the loop the object that is referenced is a BankAccount, but the second time the object is a FeeBasedAccount and the third time, it is a SavingsAccount. The method of the underlying object is called

12C draft:
12C final: