Exercises using JUnit

    I encourage you to show me, or your TA, your work if possible before submitting.

  1. Design and implement MoneyTest and Money. Use the test-first approach, as we discussed, and document each method before implementing.
    Money
    - dollars : int
    - cents : int
    + Money (int, int)
    + getDollars() : int
    + getCents() : int
    + add (Money) : Money
    + subtract (Money) : Money
    + toString() : String
    + equals (Money) : boolean
    + compareTo (Money) : int
  2. Design and implement AccountTest and Account. Use the test-first approach, as we discussed, and document each method before implementing. Also, don't re-invent the wheel, e.g. when you define your deposit method, let it call as a helper method the add method of your Money class. A transfer between accounts is a deposit to one account and a withdrawal to another; make sure your documentation is clear about which account will be deposited and which account will be withdrawn. Also note the number of, and data types of, parameters (in between parentheses in the diagram below).
    Account
    - name : String
    - id : String
    - balance : Money
    + Account (String, String, Money)
    + deposit (Money)
    + withdraw (Money)
    + transfer (Account, Money)
    + toString() : String
    + equals (Account) : boolean