MinMaxAccount
Ela-Zaman opened this issue · 0 comments
Ela-Zaman commented
Overview
You are an intern in the "CoinBox" Bank's IT department. Your supervisor asked you to add some functionality to the previous code. The code contains a large class BankingAccount with many methods including:
Method/Constructor | Description |
---|---|
BankingAccount(Startup s) |
constructs a BankingAccount object using information in the Startup object |
void debit(int debit) |
records the given debit |
void credit(int credit) |
records the given credit |
int getBalance() |
returns current balance |
Your job is to add a class MinMaxAccount that will calculate the minimum and maximum balances ever recorded for the account.
Assumptions
- Startup includes basic information such as
account_no
,account_type
and a method that returns the initial balance. - Only the
debit
andcredit
methods change an account's balance.
Task
- Design the
class Startup
that includes minimum basic information about the account. You should provide amethod getInitialBalance()
that returns the initial balance. - Implement the
class BankingAccount
. The account's constructor sets the initial balance based on the Startup information. - Design a new
class MinMaxAccount
whose instances can be used in place of a BankingAccount object but include new behaviour 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 behaviour:
Method/Constructor | Description |
---|---|
MinMaxAccount(Startup s) |
constructs a MinMaxAccount object using information in the Startup object |
int getMin() |
returns minimum balance |
int getMax() |
returns maximum balance |
Source
https://practiceit.cs.washington.edu/problem/view/bjp5/chapter9/e9-MinMaxAccount
Reminders
- React to the problem if you find it interesting and helpful. This will help others to easily identify good problems to solve.
- Feel free to comment about the problem. Is the description unclear? Do you think it is too easy or too difficult than what is mentioned? Comment about it.
- Discussion about the solution is OK. But do not paste a solution here. Give a link to the solution instead.
- Do you have an interesting problem? Post it.