Solution public class MinMaxAccount extends BankingAccount { private int min; private int max; public MinMaxAccount(Star

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Solution public class MinMaxAccount extends BankingAccount { private int min; private int max; public MinMaxAccount(Star

Post by answerhappygod »

Solution Public Class Minmaxaccount Extends Bankingaccount Private Int Min Private Int Max Public Minmaxaccount Star 1
Solution Public Class Minmaxaccount Extends Bankingaccount Private Int Min Private Int Max Public Minmaxaccount Star 1 (62.4 KiB) Viewed 13 times
Solution public class MinMaxAccount extends BankingAccount { private int min; private int max; public MinMaxAccount(Startup s) { //pass s to Banking Account(s) so MixMax accounts are setup like Banking accounts super(s); //start the min and max for this account as the starting balance min getBalance(); max = getBalance(); } //accessors for min/max public int getMin() { return min; } public int getMax() { return max; } //override the functionality of debit and credit to account for tracking min/max public void debit(Debit d) { super.debit(d); updateMinMax(); } public void credit (Credit c) { super.credit(c); updateMinMax(); } //helper method for updating balance since needed in multiple places private void updateMinMax() { min = Math.min(min, getBalance()); max = Math.max(max, getBalance()); } } Answer the following questions: 1. What is the purpose of calling super(s) in the MinMaxAccount constructor? 2. Why does calling getBalance()) in the MinMaxAccount class work when it does not appear in this file? 3. What is the purpose of calling super. credit(c) in the MinMaxAccount class's credit method? 4. Why is there an updateMinMaxMethod() method and why do you think it is private?
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply