Lab Tasks 7
Lab Tasks 7
TypeCasting
• Design child class Card and Truck with an additional field of your own choice.
Start a new project called BankManager that will contain the following classes:
CheckingAccount
SavingsAccount
CertificateOfDeposit
Make sure they all extend from the same class called BankAccount that includes all the com-
mon fields. For each type of account, think about the details of how they function. What fields
need to be declared in the parent class and what fields/methods should be specific to the child
classes.
Follow these steps and check them once you're done to complete this exercise:
1. Create a new class called BankAccount with account and balance fields.
2. Create deposit() and withdraw() methods to make changes to account balance.
3. Override a toString() method to display the fields of class BankAccount.
4. Create a new class called CheckingAccount that extends BankAccount with an extra field
called as limit.
5. Repeat the same for SavingsAccount and CertificateOfDeposit as in Step.2 above.
6. For child classes, override methods of parent classes as necessary.
In the main method, create an instance of each of the 3 child classes. Make sure you can ac-
cess the account and balance fields (set them and read them) for all account types.
Good Luck!