Carleton
University
Department of Systems and Computer Engineering
SYSC 2002 - Winter 2011
Assignment 6
This assignment involves improving your assignment #5. It includes adding a "Customer" class (that replaces the customer struct) and some restrictions on the Customer fields. You should continue to use version 2 of the Date class.
You can use your assignment #5 or the assignment #5 sample solution (to be posted after the due date) as your starting point.
You are two add two new files "Customer.h" and "Customer.cpp" to implement the customer class:
- The CustomerDB class will use the Customer class (and main will use the CustomerDB class, as well as the Customer class).
- The Customer class has the following restrictions:
- customer ids must be in the range 1 to 1000, inclusive
- total must be 0 or greater
- purchase date must be between 2000 and 2015 (any day, month)
- customer names must be between 1 and 20 characters (spaces and other special characters are permitted -- see below)
- In the Customer class, you must implement (at least) the following public methods:
- default constructor that sets the customer to id 10, total 0, date Jan 1st 2011, and name "default"
- constructor with 4 parameters that sets the customer to the values given
- if any value is unreasonable (see rules above), the customer is set to the default and the program quits
- getID: returns the id of the customer
- getTotal: returns the total of the customer
- getDate: returns the purchase date of the customer
- getName: returns the name of the customer
- setID: changes the id of the customer to that supplied (quits without changing if the value is unreasonable)
- setTotal: changes the total of the customer to that supplied (quits without changing if the value is unreasonable)
- setDate: changes the purchase date of the customer (quits without changing if the value is unreasonable)
- setName: changes the name of the customer to that supplied (quits without changing if the value is unreasonable)
- the 2 comparison operators listed below. Note that for all of these, you are to compare the customer id fields (e.g. two customers are equal if they have the same customer id, regardless of the other fields, etc.)
- print: prints the customer information (same format as used in previous assignments)
The Customer database class ("CustomerDB.h" and "CustomerDB.cpp") must also change:
- Method add now takes a customer object as an argument.
- You must add a new method "getLowestID" that uses Customer's operator<. (Hint: Keep track of the index of the lowest ID so far.)
- You must update the implementation of all your methods to use the methods of the customer class when possible. For example, if you want to look at the customer name, use getName; if you want to compare customer ids, use ==, if you want to change the customer date, use setDate, etc. (Hint: If there are any methods in the Customer class that you haven't used, you missed something!)
The updated main program ("a6main.cpp") is provided.
Refer to the sample executable if you have any questions.
If you wish, you may use "CustomerSkel.h" and "CustomerSkel.cpp" as your starting point. These will be posted after the assignment #5 due date.
Submit files "CustomerDB.h", "CustomerDB.cpp", "Customer.h", and "Customer.cpp".
Updated: Wed Feb 16th, 2011