CS49J

Remember not to create packages. Use the default package

12A

In this problem, you will write a tester class PolymorphismRunner. You are provided with three classes: BankAccount, SavingsAccount and CheckingAccount

Add the code described below to the main method

Create an array of BankAccounts that can hold 5 objects. You will fill the array with the objects specified in the table

Index Type

InitialBalance

InterestRate

Transaction Fee
0 BankAccount 1000    
1 SavingsAccount 1000 .01  
2 CheckingAccont 3000   $3
3 SavingsAccount 1000 .01  
4 SavingsAccount 2000 .012  

Loop through the array

Your output should look like this

Balance: 1090.00
Balance: 1100.01
Interest: 0.01
Balance: 3094.00
Balance: 1100.01
Interest: 0.01
Balance: 2100.02
Interest: 0.012

Codecheck URL

12B

In both the BankAccount and SavingsAccount provided, override the toString and equals methods.

Codecheck URL

12C

In both Critter and LethargicCritter classes from 11c, add equals and toString methods. You can use your own version or the one posted in the solutions. You can get a String of the array list by using the Arrays.toString method. Call super.toString in LethargicCritter's toString

Codecheck URL