logo Practice-It logo

BJP5 Exercise 9.9: MinMaxAccount

Related Links:
Author: Robert Baxter (on 2019/09/19)

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.

Type your solution here:

This is an inheritance problem. Write a Java class using inheritance. (You do not need to write any import statements.)

You must log in before you can solve this problem.

Log In

If you do not understand how to solve a problem or why your solution doesn't work, please contact your TA or instructor.
If something seems wrong with the site (errors, slow performance, incorrect problems/tests, etc.), please

Is there a problem? Contact a site administrator.