Question: please show me the code In this exercise, you will be creating new classes that are derived from a class called BankAccount. A checking account




please show me the code
In this exercise, you will be creating new classes that are derived from a class called BankAccount. A checking account is a bank account and a savings account is a bank account as well. This sets up a relationship called inheritance, where BankAccount is the superclass and CheckingAccount and SavingsAccount are subclasses. This relationship allows CheckingAccount to inherit attributes from BankAccount (like owner, balance, and accountNumber, but it can have new attributes that are specific to a checking account, like a fee for clearing a check. It also allows CheckingAccount to inherit methods from BankAccount, like deposit, that are universal for all bank accounts. You will write a withdraw method in CheckingAccount that overrides the withdraw method in BankAccount, in order to do something slightly different than the original withdraw method. You will use an instance variable called accountNumber in SavingsAccount to hide the accountNumber variable inherited from BankAccount. The UML diagram for the inheritance relationship is as follows: . . . BankAccount attributes balance:double -ow ner: String -accountNumber: String #numberOfAccounts : int operations +BankAccount) +BankAccount( name String, amount double) +BankAccount( oldAccount BankAccount, amount: double) +deposit( amount: double) void +w ithdraw ( amount: double) boolean +getBalance() double +getOw ner) String +getAccountNumber() String +setBalance( amount double) void +setAccountNumber( new AccountNumber: String): void
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
