A company has written a large class Banking Account with many methods including:
ID: 3930527 • Letter: A
Question
A company has written a large class Banking Account with many methods including: Design a new class MinMax Account whose instances can be used in place of a Banking Account object but include new behavior of remembering the minimum and maximum balances ever recorded for the account. You should provide the same methods as the superclass, as well as the following new behavior: The account's constructor sets the initial balance based on the Startup information. assume that only the debit and credit methods change an account's balance.Explanation / Answer
public class MinMaxAccount extends BankingAccount { private int min; private int max; public MinMaxAccount(Startup s) { super(s); min = getBalance(); max = getBalance(); } public void credit(Credit c) { super.credit(c); toupdatefunc(); } public void debit(Debit d) { super.debit(d); toupdatefunc(); } public void toupdatefunc() { int balance = getBalance(); if (balance max) { max = balance; } } public int getMin() { return min; } public int getMax() { return max; }Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.