Practice-It! logo

BJP3 Exercise 9.9: MinMaxAccount

Added by: Robert Baxter on 2013/04/01

A company has written a large class BankingAccount with many methods including:

Method/Constructor Description
public BankingAccount(Startup s) constructs a BankingAccount object using information in the Startup object s
public void debit(Debit d) records the given debit
public void credit(Credit c) records the given credit
public int getBalance() returns current balance in pennies

Design a new class MinMaxAccount whose instances can be used in place of a BankingAccount 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:

Method/Constructor Description
public MinMaxAccount(Startup s) constructs a MinMaxAccount object using information in the Startup object s
public int getMin() returns minimum balance in pennies
public int getMax() returns maximum balance in pennies

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.

Related Files:

You must log in before you can solve this problem.

Log In

indent Re-indent

If you do not understand how to solve a problem or why your solution code doesn't work, please contact your TA or instructor.

If something seems wrong with the Practice-It system itself (errors, slow performance, incorrect problem descriptions/tests, etc.), please contact us.

Is there a problem?
Contact a Practice-It administrator.