There are two money vaults in a bank. One of them is for the bank's own
money, the other one for borrowed and lent money. We will call the
vaults "own vault" and "loans_balance vault". The own vault may not be
negative. The loans balance vault can; a negative value means that the
bank owes money, a positive balance that people owe the bank money.
Program the class MoneyBank to implement the bank.
- public MoneyBank(double own, double loans) creates the MoneyBank
object. The starting capitals are given as parameters.
- public double getFunds() returns the value of the own vault
- public double getLoans() returns the value of the loans_balance vault
- public double getBalance() returns the bank's total balance, i.e.
the sum of the vaults
- public void deposit(double amount) adds money to the own vault
- public boolean withdrawal(double amount) takes money from the own
vault. If anyone tries to withdraw more than there is in the vault,
nothing is withdrawn and the method returns the value false. If the
withdrawal was successful, the method returns the value true.
- public boolean change loans(double amount) tries to add the value
of the parameter to the loans balance vault.. The parameter can also be
negative, meaning that the bank borrows more money. If the bank's total
balance, i.e. the sum of the vaults, was negative before the change in
loans, the bank may not borrow more money. The method returns true if
the change in loans was successful, and false if it could not borrow
more.
- public String toString() returns a clear String
presentation of the bank
Show with the help of a small main program how the class MoneyBank is
used. This program does not need to read anything.
Do not waste time in
trying to look for a real counterpart to this MoneyBank! Just write the
program as requested.
(16 points)