CS1020 -- Lab 1: Checking Account Class

Winter 2004
Objectives Addressed
Assignment

You should implement and test two classes. The Transaction class represents a transaction that may take place in a checking account. The class should accessors and mutators (get and set) for the following fields: date (GregorianCalendar), payee (String), amount (double), category (String), memo (String), status (byte where 0 represents reconciled). For example, the class should have a getPayee() method which returns a String containing the payee's name and a setPayee(String name) that sets the payee field of the object to the name that was passed to the method.

The CheckingAccount class is described by the following UML class diagram:

+--------------------------------------------------------------------------------------------+
|                                      CheckingAccount                                       |
+--------------------------------------------------------------------------------------------+
| You decide appropriate fields                                                              |
+--------------------------------------------------------------------------------------------+
|+CheckingAccount(name: String, initialDeposit: double, date: GregorianCalendar)             |
|+transact(transaction: Transaction) : void                                                  |
|+getCurrentBalance() : double                                                               |
|+getBalanceOn(day: GregorianCalendar) : double                                              |
|+getTransactionsBetween(start: GregorianCalendar, end: GregorianCalendar) : Transaction[]  |
|+getTransactions(quantity: int) : Transaction[]                                            |
|+getAdjustmentsBetween(start: GregorianCalendar, end: GregorianCalendar) : Transaction[]   |
|+getAdjustments(quantity: int) : Transaction[]                                             |
|+getCreditsBetween(start: GregorianCalendar, end: GregorianCalendar) : Transaction[]       |
|+getCredits(quantity: int) : Transaction[]                                                 |
|+getDebitsBetween(start: GregorianCalendar, end: GregorianCalendar) : Transaction[]        |
|+getDebits(quantity: int) : Transaction[]                                                  |
|                                                                                            |
| You decide appropriate private methods                                                     |
+--------------------------------------------------------------------------------------------+
Notes:
CheckingAccount(name, initialDeposit, date)

Constructor that creates a CheckingAccount object known as name with and initial balance of initialDeposit on date.

transact(transaction)

Adds the transaction (either a credit, debit, or adjustment) to the account.

getCurrentBalance()

Returns the current balance in the checking account.

getBalanceOn(day)

Returns the balance in the checking account at the end of the day.

getTransactionsBetween(start, end)

Returns an array with all of the transactions that occurred between the beginning of start and just prior to the beginning of end.

getTransactions(quantity)

Returns an array with the last quantity transactions.

Remaining methods

The remaining getXxxxBetween(start, end) and getXxxx(quantity) methods should operate like they getTransactionsBetween(start, end) and getTransactions(quantity) methods except that they should only return the appropriate transactions, e.g., (getDebits(quantity) returns an array of the previous quantity transactions that are debits.

In addition to these methods, you may choose to create additional methods. This is fine, however, any additional methods should be private.

Test program and Activity log (due 11:00pm, the day prior to week 2 lab)

You should write a program to test the implementations of the two classes you are required to write as part of this assignment. Keep in mind that you do not need to implement the classes before writing the test program.

Use the lab 1 template file to use as a starting point for this report. You can just leave the the other sections blank.

Final Lab report (due 4:00pm, Friday of week 3)

Continue using the XML file that you submitted in week 2.

The lab report need not be self-contained. Your report should include:

As with any report you submit, correct spelling and grammar are required. In addition, your report should be submitted electronically following the Electronic submission guidelines. (You may wish to consult the XML help video and/or sample report before submitting your report.) Be sure to keep copies of all your files, in case something gets lost.

Your grade will depend on quality of design, clarity of code and documentation, as well as whether your program produces the correct results. If you have any questions, consult your instructor.

Acknowledgment

This laboratory assignment was developed by Dr. Chris Taylor.

Last Updated: Thursday, 01-Jan-2015 14:30:04 EST