Menu

[Solved]Add Bank Class Note Bank Class Subclass Account Class Container Classes Kind Relationship Q37168984

Now add a Bank class. Note that the Bank class is not a subclass of the Account class. It is a container of other classes.

Wells Fargo Bank N/A Test toString() of Wells Fargo CheckingAccounts Checking A/C no:12345, Balance-123.45 Checking A/C no: 5

Now add a Bank class. Note that the Bank class is not a subclass of the Account class. It is a “container” of other classes. This kind of relationship (i.e., Bank vs. Account, SavingsAccount, or CheckingAccount) is called composition relationship, a kind of “whole-part” or “has-a” relationship. 4. The Bank class has the following members: a. Two fields as follows: i. private String bankName; ArrayList〈Account>(); private ArrayList Account〉 bankAccounts Four methods including a constructor. Note that you need to fill their bodies. public void setBankName(String name) ( new 11. public String getBankName() /Varargs. Here, the parameter accounts is treated as an array public void setBankAccounts (Account… accounts) public ArrayList<Account> getBankAccounts) b. Add a new class named TestBank with a main method to the package hw7p1. Implement the main method to test with an instance of the Bank class and two instances of CheckingAccount class and two instances of SavingsAccount class. The output should look like the following: Wells Fargo Bank N/A Test toString() of Wells Fargo CheckingAccounts Checking A/C no:12345, Balance-123.45 Checking A/C no: 56789, Balance-0.00 >Test setters and getters of a Wells Fargo CheckingAccount Checking A/C no:12345, Balance-123.45 The account Number is: 12345 The balance is: 123.45 Test setters and getters of another Wells Fargo CheckingAccount Checking A/C no:56789, Balance 567.89 The account Number is: 56789 The balance is: 567.89 Test toString() of Wells Fargo SavingsAccounts Savings A/C no: 54321, Balance 543.2:1 Savings A/C no:98765, Balance-0.00 > Test setters and getters of a Wels Fargo SavingsAccount Savings A/C no:54321, Balance 543.21 The account Number is: 54321 The balance is: 543.21 >> Test setters and getters of another Wells Fargo SavingsAccount Savings A/C no:98765, Balance 987.65 The account Number is: 98765 The balance is: 987.65 >> Test credit(), debit(), setOverdraftFee) >> getoverdraftFee) of the first Wells Fargo CheckingAccount Deposit 100 Checking A/C no:12345, Balance-223.45 Withdraw 200 Checking A/C no:12345, Balance-23.45 Withdraw 1000 Overdraft: -976.55 Checking A/C no:12345, Balance–976.55 Overdraft fee is -9.77 > Test credit(), debit() of the first Wells Fargo SavingsAccount Deposit 100 Savings A/C no: 54321, Balance 643.21 Withdraw 200 Savings A/C no:54321, Balance-443.21 Withdraw 1000 Amount withdrawn exceeds the current balance! The transaction has been cancelled! Savings A/C no:54321, Balance 443.21 Show transcribed image text Now add a Bank class. Note that the Bank class is not a subclass of the Account class. It is a “container” of other classes. This kind of relationship (i.e., Bank vs. Account, SavingsAccount, or CheckingAccount) is called composition relationship, a kind of “whole-part” or “has-a” relationship. 4. The Bank class has the following members: a. Two fields as follows: i. private String bankName; ArrayList〈Account>(); private ArrayList Account〉 bankAccounts Four methods including a constructor. Note that you need to fill their bodies. public void setBankName(String name) ( new 11. public String getBankName() /Varargs. Here, the parameter accounts is treated as an array public void setBankAccounts (Account… accounts) public ArrayList getBankAccounts) b. Add a new class named TestBank with a main method to the package hw7p1. Implement the main method to test with an instance of the Bank class and two instances of CheckingAccount class and two instances of SavingsAccount class. The output should look like the following:
Wells Fargo Bank N/A Test toString() of Wells Fargo CheckingAccounts Checking A/C no:12345, Balance-123.45 Checking A/C no: 56789, Balance-0.00 >Test setters and getters of a Wells Fargo CheckingAccount Checking A/C no:12345, Balance-123.45 The account Number is: 12345 The balance is: 123.45 Test setters and getters of another Wells Fargo CheckingAccount Checking A/C no:56789, Balance 567.89 The account Number is: 56789 The balance is: 567.89 Test toString() of Wells Fargo SavingsAccounts Savings A/C no: 54321, Balance 543.2:1 Savings A/C no:98765, Balance-0.00 > Test setters and getters of a Wels Fargo SavingsAccount Savings A/C no:54321, Balance 543.21 The account Number is: 54321 The balance is: 543.21 >> Test setters and getters of another Wells Fargo SavingsAccount Savings A/C no:98765, Balance 987.65 The account Number is: 98765 The balance is: 987.65 >> Test credit(), debit(), setOverdraftFee) >> getoverdraftFee) of the first Wells Fargo CheckingAccount Deposit 100 Checking A/C no:12345, Balance-223.45 Withdraw 200 Checking A/C no:12345, Balance-23.45 Withdraw 1000 Overdraft: -976.55 Checking A/C no:12345, Balance–976.55 Overdraft fee is -9.77 > Test credit(), debit() of the first Wells Fargo SavingsAccount Deposit 100 Savings A/C no: 54321, Balance 643.21 Withdraw 200 Savings A/C no:54321, Balance-443.21 Withdraw 1000 Amount withdrawn exceeds the current balance! The transaction has been cancelled! Savings A/C no:54321, Balance 443.21

Expert Answer


Answer to Now add a Bank class. Note that the Bank class is not a subclass of the Account class. It is a “container” of other clas… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *