Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 2) Modify the Account class as follows:
- a) Replace balance with two instance variables: checkingBalance and savingsBalance
- and modify the constructor to take two arguments checking and savings. The constructor
- initializes the two instance variables with the values given by the two arguments. Donβt
- forget to modify the test driver accordingly.
- b) Replace the credit method with two methods: creditChecking and creditSavings.
- Also, Replace the getBalance method with two methods: getCheckingBalance and
- getSavingsBalance. Note: the credit operation adds amount to the account.
- c) Add the following two new methods: debitChecking and debitSavings and their
- corresponding tests. Note: the debit operation subtracts amount from the account.
- d) Add a method moveFromCheckingToSavings (double amount)
- Also, Add a method moveFromSavingsToChecking (double amount)
- ***** You must implement these two methods using creditChecking, creditSavings,
- debitChecking and/or debitSavings as appropriate.
- Always ensure that the resulting balances do not become negative. If an account is debited
- with an amount greater than the corresponding balance, then that balance should be left
- unchanged and the method debitChecking( ) or debitSavings( ) should print a
- message indicating "Transaction amount exceeded checking balance" or "Transaction
- amount exceeded savings balance" as appropriate.
- Modify class AccountTest to test ALL of these methods.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement