Course Home | Homework | Lab Open Hours | Programming | Schedule & Lecture Notes | Submit

Saint Louis University

Computer Science 180
Data Structures

Michael Goldwasser

Spring 2007

Dept. of Math & Computer Science

Programming Assignment 01

Due: Wednesday, 31 January 2007, 8pm

Please make sure you adhere to the policies on academic integrity.

Please see the general programming webpage for details about the programming environment for this course, guidelines for programming style, and details on electronic submission of assignments.

The files you may need for this assignment can be downloaded here.


Contents:


Collaboration Policy

For this assignment, you are allowed to work with one other student if you wish (in fact, we suggest that you do so). If any student wishes to have a partner but has not been able to locate one, please let the instructor know so that we can match up partners.

Please make sure you adhere to the policies on academic integrity in this regard.


Overview

The goal of this assignment is to implement and test a CreditCard class, used to manage a typical credit card account.


Specifications

Meeting formal specifications is a vital aspect of programming. The public interface for a class serves as a contract for coordination between the implementor of the class (in this case, you) and the users of that class (in this case, you and the rest of the class). As part of this assignment, we are providing a header file, CreditCard.h, which defines the public interface for the CreditCard class. This includes signatures for the required public member functions. Formal documentation has been embedded in the source code and is viewable here.

We continue by explaining the basic semantics of those methods as follows. Please make sure that you carefully read and follow the specifications outlined in this section when designing your program. If you feel that there are any ambiguities, ask for clarification before completing the assignment.

A CreditCard instance manages aspects of a typical credit card account. Some of the functionality is rather basic, for example keeping track of the owner's name, the card number, the credit limit. There must also be basic support for managing the up-to-the-minute balance on the account, including allowing for the customer to make charges against the card (though not exceeding the limit) and making payments to pay off some portion of the current balance.

The most challenging aspect of our specification is that your class must also manage the typical monthly cycle for a credit card. A customer can stay in good grace by paying off the entire previous balance (even if new charges this month means that the current balance is non-zero). A good customer is never charged interest or fees. However additional charges are accrued when the previous balance is not paid off. In particular, once a customer loses good graces, interest is charged on the entire current balance (old charges and new charges). Furthermore, if the customer did not even meet the minimum payment schedule established by the company, an additional late fee is assessed.

More formally, at the end of each hypothetical month, an endOfMonth method should be triggered, starting the bookkeeping process. It is at this time that interest and fees may be assessed and when the minimum payment is determined for the coming month. The rules used are as follows.

The official set of public methods which must be supported is as follows:

The constructor

The constructor allows for general customization of the initial state of a credit card account. The parameters should be used to initialize the underlying state of the respective attributes. Notice that the initial balance provides a default parameter value of 0. Typically a new account will start with such a balance, however we leave open the possibility that someone may open a new credit card while transferring a non-zero balance from elsewhere.

There will likely be underlying attributes in addition to those listed here as parameters. Those should have initial values which are not customizable. For example, the minimum required payment for the first month of a new card is automatically zero (even with a non-zero starting balance).

Accessors

There are seven standard accessor functions to return the values of respective aspects of the underlying state. Those signatures are:

Mutators

Note Well: None of your methods should generate any output. We have provided an implementation already for the output stream operator (<<) and the user of a credit card can print their own information based on values returned by the standard accessors.


An example

As an example, assume a new card is created with zero balance and 0.79% monthly interest (approximately 9.5% per year). During the first month,charges of $25, $500 and $100 are made to the card. When endOfMonth() is called, no late charge or interest charge should be incurred, because there was no minimum payment or balance as of the beginning of the month. However at this time, the current balance of $625 and a minimum payment of $31 is recorded.

Continuing, lets assume that the next month includes new charges totaling $228, and payments totaling $300. If endOfMonth() is again called, the processing should be handled as follows. The received payments of $300 surpass the minimum monthly requirement of $31, so no late charge is assessed. However, the $300 does not constitute payment in full against the previous monthly balance of $625. Therefore interest will be computed based on the current balance which is $553 ($625+$228-$300). At the specified rate, an interest charge of $4.37 is added to the balance, resulting in an end of the month balance of $557.37, and an associated minimum monthly payment of $30.

In the next month, assume that charges of $300 are incurred, and a payment of $600 is received. In this case, at the end of the month, no late fees or interest are charged, because the payment of $600 exceeds the previous month's balance of $557.37. At this point the updated balance of $257.37 ($557.37+$300-$600) is recorded, along with a minimum monthly payment of $30.

In the next month, assume that there is no activity on the card. Because there is an unpaid balance of $257.37, an interest charge of $2.03 is added to the balance. Worse yet, because not even the minimum payment from the previous statement was paid, a late charge of $20 is added to the balance. Therefore the new balance is $279.40. The minimum payment assigned for the subsequent month is again $30.


Your Private Implementation

Thus far, we have given a clear explanation of the public semantics of the class, and examples of several scenarios. However we have said nothing at all about how you are to implement this. Based on the concept of encapsulation, it is up to you how to accomplish this.

You may feel free to add any private members that you wish to the original definition in CreditCard.h. Clearly, some basic attributes will be necessary to store the information needed for the standard accessor methods. However you will likely need to store additional internal information to properly support the specifications.

We strongly suggest that you think a bit about your design before getting too far into your implementation.


Testing your Credit Card class

For this assignment, we wish to have you submit your own version of a test program which utilizes the CreditCard class. Your test may only use the public behaviors which have been defined for this assignment. As part of the assignment, we will attempt to run your test program on everyone's CreditCard implementation as well as your CreditCard implementation on everyone's test program.

To get you going, we provide an initial implementation of Test_CreditCard.cpp which simulates the first two months of activity as described in this handout. However you should go on to add additional such tests. Those two months do not demonstrate a complete set of scenarios which may arise. We will certainly test more possibilities when we grade your program! program!)


Grading Standards

The assignment is worth 10 points.

Files You Will Need

Rather than have the entire project in a single file, we would like to shift to a more standard development practice where components of a program are stored in a combination of different files which support better reuse of components. Please read Chapter 1.3 (pp. 75-81) of our text for a similar discussion in the breakdown of the Clock program into three pieces.

For this assignment, we are actually providing four different files. These files can either be downloaded from this website, or copied directly into your account on turing, with the command

    cp -R ~goldwasser/public/csci180/Program/credit .

The four files are:


Submitting Your Assignment

Please see details regarding the submission process from the general programming web page, as well as a discussion of the late policy.

You should submit four files:


Extra Credit (1 point)

Details forthcoming...


Michael Goldwasser
CSCI 180, Spring 2007
Last modified: Tuesday, 30 January 2007
Course Home | Homework | Lab Open Hours | Programming | Schedule & Lecture Notes | Submit