Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Can you please upload the screenshots of the output. Thanks Step 1 List the classes that are part of the hierarchy In our case, the
Can you please upload the screenshots of the output. Thanks
Step 1 List the classes that are part of the hierarchy In our case, the problem description yields two classes: SavingsAccount and CheckingAccount. Of course, you could implement each of them separately. But that would not be a good idea because the classes would have to repeat common functionality, such as updating an account alance. We need another class that can be responsible for that common functionality. The problem statement does not explicitly mention such a class. Therefore, we need to discover it. Of course, in this case, the solution is simple. Savings accounts and checking accounts are special cases of a bank account. Therefore, we will introduce a common superclass BankAccount. Organize the classes into an inheritance hierarchy. Draw an inheritance diagram that shows super- and subelasses. Here is one for our example Step 2 BankACcount Savings Account Checking Account Determine the common responsibilities. In Step 2, you will have identified a class at the base of the hierarchy. That class needs to have sufficient responsibilities to carry out the tasks at hand. To find out what those tasks are, write pseudocode for processing the objects Step 3 For each user eommand If it is a deposit or withdrawal Deposit or withdraw the amount from the speifed account. Print the balance. If it is month end processing For each account Call month end processing. Print the balance. From the pveudocode we obtainthe follwing ist of commen responsibilities that every bank From the pseudocode, account must carry out: Deposit money Withdraw woney Get the balance. Carry out month end processing. Step 4 Decide which methods are overridden in subclasses. t ach of the common responsibilities, decide whether the behavior can be inherited or whether it needs to be overridden. Be su Inheritance Inheritance 1. Override the toString method of the Account class 2. Override the equals method of the Account class 3. Create an object of each type: Account, CheckingAccount, SavingsAccount 4. Use for-eaco lo of trata wrh printing information about 5. Use a for-each loop to iterate over the list printing information about the accounts 6. Sort the ArrayList using Collections.sort(list) 7. Use a for-each loop to iterate over the list printing information about the accounts Stockton University All rights reserved
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started