Advertisement
Guest User

Untitled

a guest
Feb 16th, 2020
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. 2) Modify the Account class as follows:
  2. a) Replace balance with two instance variables: checkingBalance and savingsBalance
  3. and modify the constructor to take two arguments checking and savings. The constructor
  4. initializes the two instance variables with the values given by the two arguments. Don’t
  5. forget to modify the test driver accordingly.
  6. b) Replace the credit method with two methods: creditChecking and creditSavings.
  7. Also, Replace the getBalance method with two methods: getCheckingBalance and
  8. getSavingsBalance. Note: the credit operation adds amount to the account.
  9. c) Add the following two new methods: debitChecking and debitSavings and their
  10. corresponding tests. Note: the debit operation subtracts amount from the account.
  11. d) Add a method moveFromCheckingToSavings (double amount)
  12. Also, Add a method moveFromSavingsToChecking (double amount)
  13. ***** You must implement these two methods using creditChecking, creditSavings,
  14. debitChecking and/or debitSavings as appropriate.
  15. Always ensure that the resulting balances do not become negative. If an account is debited
  16. with an amount greater than the corresponding balance, then that balance should be left
  17. unchanged and the method debitChecking( ) or debitSavings( ) should print a
  18. message indicating "Transaction amount exceeded checking balance" or "Transaction
  19. amount exceeded savings balance" as appropriate.
  20. Modify class AccountTest to test ALL of these methods.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement