UMBC CMSC 202
UMBC CMSC 202 CSEE | 202 | current 202

CMSC 202 Spring 2005
Project 3

Bigger and Better R & W Car Rental Company

Assigned March 28, 2005
Design Due 11:59pm on April 3, 2005
Program Due 11:59pm on April 10, 2005
Updates 27 March 2005
In view of a couple of student questions, the wording in the project 3 design was clarified with respect to an acceptable design of the bi-directional car/customer relationship.


Objectives


Project Description

In project 2, the R & W Car Rental Company contracted with you to develop a car rental system which allowed the company to maintain a list of mid-size cars owned by the rental company and a list of customers who rent the cars. Due to your efforts in project 2, R & W has decided to expand their business and contract with you again. R & W will now rent not only mid-size cars, but economy and luxury cars as well. Your project 2 code must now be modified to handle all three types of cars for project 3. The functionality and reporting of the car rental system have been expanded and slightly modified from project 2. The primary differences are summarized here and detailed below.
  1. Cars now have types -- luxury, economy, mid-size
  2. Cars may be "junked" due to old age or high mileage. These cars are removed from the rental system.
  3. PLATINUM card customers may now rent multiple cars simultaneously.
  4. Customers may have their rental privileges revoked. These customers are removed from the rental system.

The car rental system

The car rental system must maintain information about each car the company owns, each customer who can rent a car, and information about which cars are currently rented. The basic functional requirements of the car rental system are detailed below.
  1. Add a new car to the rental system -- self explanitory.
  2. Add a new customer to the rental system - self explanitory
  3. Rent a car to a customer -- associate the car and the customer.
  4. Return a car.
    When a renter returns a car, the number of days and mileage driven are specified. The total rental cost is calculated and added to the customer's balance due to the company. A "receipt" is printed for the renter which contains all car rental information, all renter information and the breakdown of the rental cost. See the
    sample output below.
  5. Print a list of all cars.
    All available information about each car is printed. If a car is currently rented, all customer information for the renter is also printed.
  6. Print a list of customers
    All information about each customer (including balance due and the license tag numbers of cars currently rented) is printed.
  7. Remove a customer -- self explanitory
    It is an error to attempt to remove a customer who is currently renting a car.
  8. Remove a car -- self explanitory
    It is an error to attempt to remove a car that is currently rented.
The R & W Car Rental Company has the following policies
  1. You must be 18 years old to rent a car.
  2. PLATINUM car holders may rent multiple cars simultaneously. GOLD card members may rent just one car at a time.

Cars

Cars rented by the R & W Car Rental Company for this project are basically the same as those described in project 2. Each car is described by its model (a string which may contain spaces) and uniquely identified by its license tag ( a string without spaces ). In addition, each car is now specified by type as economy, mid-size or luxury. The calculations for car rental and insurance used in project 2 are the calculations now used for mid-size cars. New table entries for economy and luxury cars are provided below. See the project 1 specification for sample calculations.

Car Rental Schedule

Car Type Card Type Weekly Charge Daily Charge Mileage Charge
Economy GOLD $90.00 $20.00 First 100 miles FREE
$0.20 per mile over 100 miles
PLATINUM $80.00 $15.00 First 200 miles FREE
$0.12 per mile over 200 miles
Mid-Size GOLD $150.00 $30.00 First 200 miles FREE
$0.20 per mile over 200 miles
PLATINUM $100.00 $20.00 First 250 miles FREE
$0.12 per mile over 250 miles
Luxury GOLD $200.00 $40.00 First 250 miles FREE
$0.20 per mile over 250 miles
PLATINUM $150.00 $25.00 First 300 miles FREE
$0.12 per mile over 300 miles

Weekly Car Insurance Premiums

Car Type Card Type Under 25 25 and Over
Economy GOLD $12.00 $9.00
PLATINUM $6.00 $4.00
Mid-Size GOLD $15.00 $12.00
PLATINUM $8.00 $6.00
Luxury GOLD $18.00 $14.00
PLATINUM $10.00 $8.00
Note - A full weekly premium must be paid for a partial week.
Insurance premiums are NOT prorated.

Customers

Customers who rent cars from the R & W Car Rental Company in this project are basically the same as those described in project 2. Each customer has a name, age and membership card. Membership cards currently come in only two types, "GOLD" and "PLATINUM" and are imprinted with a unique 6-digit membership number in the form 12-3456.

Program Description

Your assignment is to write a program that simulates the rental car company reservation system described above. The main portion of your program will read commands from a file and perform the requested action (i.e. adding a car or customer, renting a car, returning a car, producing some output).

You will implement C++ class which will be used by the main portion of your program.

Code from project 2 should be reusable in project 3.

Program Requirements

General Requirements

  1. Your program must echo each command and command parameter read from the command file.
  2. The name of the command file will be the one and only command line argument.
  3. In keeping with course standards, main( ) will be implemented in a file named Proj3.cpp. The prototypes for any helper functions called from main( ) will be located in Proj3Aux.h and the functions themselves implemented in Proj3Aux.cpp. Each class will be defined in a separate header (e.g. Customer.h) file and implemented in a similarly named .cpp file (e.g. Customer.cpp). You must provide a makefile for this project which compiles and links all files when the grader types make Proj3. Your executable must be named Proj3.
  4. You MUST overload the "plus equal" operator for the rental system class and use it to add cars and customers to the rental system.
  5. You MUST overload the "minus equal" operator for the rental system class and use it to remove cars and customers from the rental system.
  6. See the design assignment for restrictions on your design and implementation with respect to rental and insurance calculations and associating cars with customers.

  7. All private data members of your Car and Customer classes except built-in data types (int, char, etc.) must be dynamically allocated.
  8. Because of the requirement for dynamically allocated memory above, proper design dictates that you must implement the copy constructor, assignment operator and destructor for your Car and Customer classes.

    These last two requirements are for purely academic reasons -- you need experience writing code that performs dynamic memory management. There is no project functionality that would otherwise require any dynamic memory allocation.

Note that not all of the programming details have been spelled out for you. For example, the project description indicates that a customer balance due the company must be printed, but there's no specification about where that data should be stored. Also, the reservation system must keep track of which car is rented by whom, but there's no indication about how that should be done. This is intentional....you are required to give the project design serious thought before writing code.

Program Error Checking

Your program must provide adequate error checking in support of the policies of the car rental system listed above. In addition, invalid commands and any commands which cannot be carried out (i.e. trying to rent a car to a non-existent customer, trying to junk a car that is currently rented to someone) must also result in an appropriate error message.

Program Output

Your program's output must adhere to the following requirements. See the
sample output below.
  1. Customer membership card numbers must be displayed in the form 12-3456.
  2. All monetary values must be displayed with 2 decimal places.
  3. When displaying a list of cars or customers, data must be aligned in columns.
  4. Renter names must be displayed last name first.
For purposes of formatting output only, you may make the following assumptions which are the same as project 1.
  1. The renter's first and last name total no more than 20 characters.
  2. The car's model is no more than 20 characters.
  3. The car's license tag number is no more than 8 characters.
  4. Days rented and miles driven are less than 10000.
  5. The total rental charge is less than $100000.
  6. A customer will not rent more than 2 cars at a time.

The Command File

The command file has the following format. Each command and all of its parameters appear on one line. You may assume that valid commands are properly formatted and all data elements are the appropriate type. You may not assume all commands are valid. Blank lines may be found anywhere in the file and should be ignored.

The following sample command file was used to produce the sample output. CAR MIDSIZE 123-ABC Honda CAR ECONOMY 124-xyz Your Honda CAR LUXURY XYZZY My Honda PRINT CARS CUSTOMER Bob Smith 33 GOLD 123456 CUSTOMER Billy Smith 44 PLATINUM 654 PRINT CUSTOMERS RENT 124-xyz 123456 RENT 123-ABC 123456 RENT 123-ABC 654 RENT XYZZY 654 PRINT CUSTOMERS PRINT CARS RETURN 123-ABC 10 400 RETURN 124-xyz 20 300 PRINT CARS PRINT CUSTOMERS JUNK 123-ABC PRINT CARS REVOKE 123456 PRINT CUSTOMERS

Sample Output

This sample output was produced from the sample command file above. It is only a sample. It is not necessary that your output match the format exactly, but you must adhere to the
program output requirements above. CMD: CAR, MIDSIZE, 123-ABC, Honda CMD: CAR, ECONOMY, 124-xyz, Your Honda CMD: CAR, LUXURY, XYZZY, My Honda CMD: PRINT CARS Tag Type Model Renter ---------- -------- --------------- ----------------------------------------- 123-ABC MIDSIZE Honda 124-xyz ECONOMY Your Honda XYZZY LUXURY My Honda CMD: CUSTOMER, Bob, Smith, 33, GOLD, 123456 CMD: CUSTOMER, Billy, Smith, 44, PLATINUM, 654 CMD: PRINT CUSTOMERS Name Balance Age Card Car(s) -------------------- --------- --- ------------------ --------------- Smith, Bob 0.00 33 12-3456 / GOLD Smith, Billy 0.00 44 00-0654 / PLATINUM CMD: RENT, 124-xyz, 123456 CMD: RENT, 123-ABC, 123456 Unable to rent car 123-ABC to 123456 CMD: RENT, 123-ABC, 654 CMD: RENT, XYZZY, 654 CMD: PRINT CUSTOMERS Name Balance Age Card Car(s) -------------------- --------- --- ------------------ --------------- Smith, Bob 0.00 33 12-3456 / GOLD 124-xyz Smith, Billy 0.00 44 00-0654 / PLATINUM 123-ABC XYZZY CMD: PRINT CARS Tag Type Model Renter ---------- -------- --------------- ----------------------------------------- 123-ABC MIDSIZE Honda Smith, Billy 00-0654 / PLATINUM 124-xyz ECONOMY Your Honda Smith, Bob 12-3456 / GOLD XYZZY LUXURY My Honda Smith, Billy 00-0654 / PLATINUM CMD: RETURN, 123-ABC, 10, 400 Rental Return Receipt ------ ------ ------- R & W Car Rental hereby acknowledges that the car described below MIDSIZE Honda, license plate tag 123-ABC has been returned to the company by the renter Smith, Billy (00-0654 / PLATINUM ) who agrees to pay the following charges Daily Charge: 160.00 Mileage Charge: 18.00 Insurance Charge: 12.00 Total Charge: 190.00 CMD: RETURN, 124-xyz, 20, 300 Rental Return Receipt ------ ------ ------- R & W Car Rental hereby acknowledges that the car described below ECONOMY Your Honda, license plate tag 124-xyz has been returned to the company by the renter Smith, Bob (12-3456 / GOLD ) who agrees to pay the following charges Daily Charge: 300.00 Mileage Charge: 40.00 Insurance Charge: 27.00 Total Charge: 367.00 CMD: PRINT CARS Tag Type Model Renter ---------- -------- --------------- ----------------------------------------- 123-ABC MIDSIZE Honda 124-xyz ECONOMY Your Honda XYZZY LUXURY My Honda Smith, Billy 00-0654 / PLATINUM CMD: PRINT CUSTOMERS Name Balance Age Card Car(s) -------------------- --------- --- ------------------ --------------- Smith, Bob 367.00 33 12-3456 / GOLD Smith, Billy 190.00 44 00-0654 / PLATINUM XYZZY CMD: JUNK 123-ABC CMD: PRINT CARS Tag Type Model Renter ---------- -------- --------------- ----------------------------------------- 124-xyz ECONOMY Your Honda XYZZY LUXURY My Honda Smith, Billy 00-0654 / PLATINUM CMD: REVOKE 123456 CMD: PRINT CUSTOMERS Name Balance Age Card Car(s) -------------------- --------- --- ------------------ --------------- Smith, Billy 190.00 44 00-0654 / PLATINUM XYZZY

Free Advice and Information

  1. Carefully consider your class design. In general, a minimal class interface is best. Consider how best to reuse code. Plan for the future reuse of code you write in this project.
  2. Consider using static data in one of your classes.
  3. Enums are better than "const int" in many cases.
  4. Consider using the overloaded operator<< to output your classes. Even if not necessary in your code, you may find it helpful when debugging.
  5. Write your project code without any dynamic memory first. Once you have a perfectly working project without dynamic memory, submit that project, then go back and add in the dynamic memory management.
  6. Functions called from main( ) that are not part of any class are permitted. If you create new functions, their prototypes must be found in Proj3Aux.h and they must be implemented in Proj3Aux.cpp.
  7. Your program must provide adequate error checking as described above.
  8. Think carefully about the proper use of const for parameters and member functions. Doing const correctly from the beginning can save lots of effort and frustration later.
  9. Review the class notes on the different methods of passing parameters. Each is best for a different situation.
  10. Be sure your function header comments list the pre- and post-conditions and handle each pre-condition that is not met.
  11. Your program will be tested with a variety of conditions.
  12. Use incremental development.
  13. Expect to use/modify code from this project in project 4. Design and code accordingly.

Project Design Assignment

Your project design document for project 3 must be named p3design.txt. Be sure to read the
design specification carefully. Submit your design in the usual way: submit cs202 Proj3 p3design.txt

Project Makefile

You must provide the makefile for this project. Use the makefile you submitted for project 2 and modify it appropriately. If you don't change the names of the files from project 2, the changes will be minimal.

The graders will be typing the command make Proj3 when they grade your project. This command must cause all .cpp files to be compiled and the executable named Proj3 to be created.

The make utility can also be used for compiling a single program without linking. For example, to compile Box.cpp, type make Box.o.

In addition to compiling and linking your files, make can be used for maintaining your directory. Typing make clean will remove any extraneous files in your directory, such as .o files and core files. Typing make cleanest will remove all .o files, core, Proj3, and backup files created by the editor. More information about these commands can be found at the bottom of the makefile.


Grading

The grade for this project will be broken down as follows. A more detailed breakdown will be provided in the grade form you receive with your project grade.

85% - Correctness

This list may not be comprehensive, but everything on this list will be verified by the graders.

15% - Coding Standards

Your code adheres to the CMSC 202 coding standards as discussed and reviewed in class.
In particular, since this is your first C++ program using classes, pay attention to the list below. Graders will check all applicable items in the coding standards.
  1. Your class implementation and class usage
  2. Proper use of const
  3. Your function header comments (particularly pre- and post-conditions)
  4. In-line comments
  5. Code readability

Project Submission

Submit all your files in the usual way. You must make sure that all files necessary to compile and link your project (using the makefile) are listed. You need not submit all files at the same time. You may resubmit your files as often as you like, but only the last submittal will be graded and will be used to determine if your project is late. For more information, see the projects page on the course website.

You can check to see what files you have submitted by typing

submitls cs202 Proj3

More complete documentation for submit and related commands can be found here.

Remember -- if you make any change to your program, no matter how insignificant it may seem, you should recompile and retest your program before submitting it. Even the smallest typo can cause compiler errors and a reduction in your grade.

Avoid unpleasant surprises!

Be sure to use the submitmake and submitrun utilities provided for you to compile, link and run your program after you've submitted it.


Last Modified: Sunday, 27-Mar-2005 11:00:42 EST