User Defined Types  «Prev  Next»

Drawing Class Diagram - Exercise Result

You entered:

Define all class data for the Checkbook Manager program

The first step is to choose your classes. Your classes may have different names, but keep in mind that throughout the rest of the course, I will be referencing the following class names. Here's my trimmed-down list:
  1. Money
  2. CheckingAccount
  3. Check
  4. CheckList
  5. Deposit
  6. DepositList
  7. Date
  8. Bank

Creating class diagrams

You have already seen diagrams for the CheckList, DepositList, Money, and Date classes. They do not need to be changed.

Money
dollars: Integer
cents: Integer

Date
year: Integer
month: Integer
day: Integer

CheckList
checks: Check[]

DepositList
deposits: Deposit[]
The Check class is not going to be all you need in the long run: How will you represent cash withdrawals, transfers to your savings, and the like? It is possible to use "Cash" or "Savings" as the payee, and that will do for now. You have seen the Check class already, and the Deposit class is just a little simpler:

Check
number: Integer
date: Date
payee: String
amount: Money
memo: String

Deposit
date: Date
amount: Money
memo: String

This leaves only the CheckingAccount class. The account must store the account number, balance, a list of checks, a list of deposits, and the bank or institution where the account is held:

CheckingAccount
homebank: Bank
checks: CheckList
deposits: DepositList
balance: Money
accountnumber: String

Finally, we draw a diagram that shows how these classes fit together, omitting their attributes.

Bank Relationships 1) CheckingAccount 2) Bank 3) Money 4) CheckList 5) DepositList
Bank Relationships 1) CheckingAccount 2) Bank 3) Money 4) CheckList 5) DepositList

Notice that the Money class appears three times on my diagram. You might have drawn three lines to it instead: Either is correct.
The * on the lines from CheckList to Check and from DepositList to Deposit indicate that any number of Checks can be associated with CheckList and any number of Deposits can be associated with DepositList.