A company has written a large class Banking Account with man

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.

Solution

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 < min) { min = balance; } else if (balance > max) { max = balance; } } public int getMin() { return min; } public int getMax() { return max; }
 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 Ba

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site