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

CMSC 202 Fall 2005
Project 3

Netflux - An Overloaded Internet-based Movie Rental

Assigned October 21, 2005
Design Due 11:59pm on Sunday, October 30, 2005
Program Due 11:59pm on Sunday, November 6, 2005

Bug Reports - Utility.o
  • 10-24 - State abbreviation does not accept mixed case (from: A. Carts - Congrats on the first bug!) - Utility.o updated
  • 10-26 - The Utility class inserts an extra space after the city (from: S. Yee) - Utility.o updated
Things you wish were bugs, but aren't...
  • 11-4 The Utility.o file treats lines that have 1 or more characters (even if the character is a space) as a command - which means that if you have a line with a single space on it, and nothing else - the GetCommand method will treat that line as an invalid command, NOT as a blank line.
  • 10-25 States abbreviations include 50 states, not DC or the other valid postal codes. This is acceptable - the specification includes ONLY the 50 states.
  • 10-24 Customer command allows for address to be a single space. This is acceptable (just not in the real-world) - the specification includes PRINTABLE characters (anything you can type).
  • 10-26 Zip code (and all other digit-based parameters) are not range validated (i.e. a zip-code that is too small is permitted). The Utility class does not range-validate numbers, it just ensures that only digits are permitted.
Updates
  • 11-4 PRINT_USERS - eliminated bullet on "rentals" since it is irrelevant
  • 11-3 Makefile description updated - must use /usr/local/bin/g++ compiler.
  • 10-28 Dynamic Memory section updated - All instances of user-defined classes (RentalSystem, Customer, DVD) must be dynamic memory.

Objectives


Project Description

In this third phase of the project you will be experimenting with different forms of representing data as well as overloading operators to enhance the readability of your code.

The DVD rental system

The DVD Rental System manages a list of customers who want to rent DVDs, a list of available DVDs, and a list of desired DVDs for each customer (the customer's "queue"). The system also reacts to the following commands:

OPEN

CUSTOMER

RENT

RETURN

QUEUE

PRINT_DVDS

PRINT_CUSTOMERS

PRINT_USER

Data

Rental System

The Rental System manages the collection of Customers and in-stock DVDs. You may also have the Rental System manage other components according to your design. However, for this project, your Rental System class MUST have at the minimum:

Customers

Customers who rent DVDs are essentially the same as in Project 1. There are multiple customers allowed in the system. Each customer is charged $0.99 per disc to rent a DVD. Customers are limited to a MAXIMUM of 3 rentals at a time.

Customers each have the following information, you may represent these in a variety of ways and are not limited to this exact representation:

DVDs

DVDs are essentially the same as described in Project 1. Multiple copies of the same DVD are allowed. It can be assumed that the first DVD added to the system has the correct Number of Discs and Title information.

DVDs each have the following information:


Program Requirements

Dynamic Memory UPDATED!

You are required to declare all instances of user-defined classes of type RentalSystem, Customer and DVD as dynamic memory (pointers!). You a re not required to declare strings and vectors as dynamic objects (vectors may, however, be built of dynamic objects, example: a vector of pointers to Customers). If you have other user-defined classes, they need not by dynamically allocated - this is your choice.

You are required to overload the "Big Three" methods for each class that uses dynamic memory to create, manage, and delete all dynamic memory.

Operator Overloading

You will extend your classes from Project 2 to accomodate the following:

You may include any other classes that you feel are necessary or reasonable - these represent the minimum set of classes that you must use.

Utility Class

You have been provided with a "Utility" class that has one static method that you may use to correctly parse the command file. If you choose not to use the Utility class, then you will have to rely upon the correctness of your own implementation. You have been provided with the .h and .o files. You will not be supplied with the Utility class code, you do not need it.

You can find Utility.o and Utility.h in the following location:

/afs/umbc.edu/users/d/a/dana3/pub/CMSC202/p3/

The one public method of the Utility class is:

static bool GetCommand(istream& sin, vector& command);
The GetCommand method makes the following guarantees: Although you do not have the actual code, you should be able to easily modify your code to use this in place of your own implementation. There are constants for each command included in the Utility.h so you do not have to declare those in your own code.

Extra Credit

Utility Class (Possible 10 pts)

As a professional developer, you will often have to use code developed by other individuals both within your company and without. This is the purpose of introducing the Utility Class at this point - Code Reuse. One of the problems with using code written by others is that it might have bugs in it.

You have the opportunity to earn up to 10 extra credit points by finding a bug in the Utility class. It is not guaranteed that one exists, but if you are the first to point it out to Ms. Wortman, and provide the test case in which the bug was found, you will receive up to 10 points. The first person to point out each individual error will receive the points. Ms. Wortman will ensure that the graders give you the appropriate points.

PRINT SORTED CUSTOMERS (Possible 10-20 pts)

Add support in your system for the command PRINT SORTED that will print the list of customers in alphabetical order by username. There are a variety of sorting algorithms that you can use from easy to hard. The four that we will give credit for are:

Calling the PRINT_SORTED_CUSTOMERS command cannot make a permanent change to the original printing order of the customers (i.e. a call to PRINT_CUSTOMER before and after the PRINT_SORTED_CUSTOMERS command should print out the customers in exactly the same order as before.

In order to get credit for this, you must submit a README file for the graders describing your implementation. Describe your strategy and which sort you used. Also describe which data-structure decisions that you made (i.e. How did you store the customers to prevent change?). You may only select one algorithm to implement and get credit for.

Command File Requirements

The name of the command file will be read from the command line. You should thoroughly test your program by developing your own command file. You do not need to submit your command file. We will test your program using our own command file(s).

Your program is required to repeat the command as read from the file. The Utility class will take care of this for you, if you use it.

Commands

Please note that there have been minor changes to the command parameters

Valid commands for the system are as follows:

Command File Error Checking

Sample Command File

OPEN stock.txt CUSTOMER Fred Flintstone fflint0 1234123456785678 123 Bedrock LN Apt. 7 Rock Vegas NV 12345 QUEUE 12345 fflint0 QUEUE 928173 fflint0 QUEUE 32145 fflint0 QUEUE 759203 fflint0 RENT fflint0 CUSTOMER Barney Rubble brubblerubble 1234567812345678 123 Bedrock LN Apt. 8 Rock Vegas NV 12345 QUEUE 927833 brubblerubble QUEUE 12345 brubblerubble RENT brubblerubble PRINT_USER brubblerubble RETURN 826918 fflint0 RETURN 12345 fflint0 PRINT_DVDS PRINT_CUSTOMERS PRINT_USER fflint0

Stock File

You can assume that any stock file that we test with your program is properly formatted and that all DVD data is valid. You need not perform ANY error checking on the DVD file. The stock file represents all the DVDs that are currently "in-stock" (since the inventory is taken every evening). For now, you will assume that another file processes the inventory every evening and provides your system with an up-to-date copy of the stock every morning.

Sample Stock File

12345 2 Harry Potter and the Chamber of Secrets 423644 1 Matrix: Reloaded 826918 4 Lord of the Rings: The Fellowship of the Ring 759203 1 Dumbo 927833 3 Hunt for Red October 32145 1 Pi 928173 1 Hitchhiker's Guide to the Galaxy

General Requirements

Note that not all of the programming details have been spelled out for you. For example, the rental system must keep track of which DVD 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. Remember to think ahead to what might be assigned in future projects and design your classes so that they are easily modifiable.


Program Output

Your program's output must adhere to the following requirements:
  1. Customer credit card numbers must be displayed in the form 1234-5678-9012-3456.
  2. All monetary values must be displayed with 2 decimal places.
  3. When displaying a list of DVDs or customers, data must be aligned in columns.
  4. Lists of DVDs/customers shall be displayed in the order DVDs/customers are added to the rental system.
  5. As the stock file is processed, messages informing the user of each DVD that is being added shall be displayed
For purposes of formatting output only, you make the following assumption:
  1. The renter's first and last name total no more than 20 characters.
  2. The renter's username totals no more than 20 characters.

Sample Output

This sample output was produced from the sample command file above paired with the sample stock 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: OPEN stock.txt ADDED: 12345 2 Harry Potter and the Chamber of Secrets ADDED: 423644 1 Matrix: Reloaded ADDED: 826918 4 Lord of the Rings: The Fellowship of the Ring ADDED: 759203 1 Dumbo ADDED: 927833 3 Hunt for Red October ADDED: 32145 1 Pi ADDED: 928173 1 Hitchhiker's Guide to the Galaxy CMD: CUSTOMER Fred Flintstone fflint0 1234123456785678 CMD: 123 Bedrock LN Apt. 7 CMD: Rock Vegas NV 12345 CMD: QUEUE 12345 fflint0 CMD: QUEUE 928173 fflint0 CMD: QUEUE 32145 fflint0 CMD: QUEUE 759203 fflint0 CMD: RENT fflint0 ------------------------------------------------------------------ RENTAL RECEIPT --------------------- Customer Information --------------------- Name: Fred Flintstone Card: 1234-1234-5678-5678 Username: fflint0 Address: 123 Bedrock LN Apt. 7 Rock Vegas NV 12345 --------------------- Rental Requests --------------------- Number Discs Title ------- ----- -------------------------------------------- 012-345 2 Harry Potter and the Chamber of Secrets 928-173 1 Hitchhiker's Guide to the Galaxy 032-145 1 Pi --------------------- Charges Detail --------------------- DVD Discs Per Disc Subtotal -------- -------- -------- -------- 012-345 2 $ .99 $ 1.98 928-173 1 $ .99 $ .99 032-145 1 $ .99 $ .99 -------- TOTAL $ 3.96 ------------------------------------------------------------------ CMD: CUSTOMER Barney Rubble brubblerubble 1234567812345678 CMD: 123 Bedrock LN Apt. 8 CMD: Rock Vegas NV 12345 CMD: QUEUE 927833 brubblerubble CMD: QUEUE 12345 brubblerubble CMD: RENT brubblerubble ------------------------------------------------------------------ RENTAL RECEIPT --------------------- Customer Information --------------------- Name: Barney Rubble Card: 1234-1234-5678-5678 Username: brubblerubble Address: 123 Bedrock LN Apt. 8 Rock Vegas NV 12345 --------------------- Rental Requests --------------------- Number Discs Title ------- ----- -------------------------------------------- 927-833 3 Hunt for Red October --------------------- Charges Detail --------------------- DVD Discs Per Disc Subtotal -------- -------- -------- -------- 927-833 3 $ .99 $ 2.97 -------- TOTAL $ 2.97 ------------------------------------------------------------------ CMD: PRINT_USER brubblerubble ------------------------------------------------------------------ Barney Rubble (brubblerubble) has the following DVDs in queue: Number Discs Title ------- ----- -------------------------------------------- 012-345 2 Harry Potter and the Chamber of Secrets ------------------------------------------------------------------ CMD: RETURN 826918 fflint0 ERROR: fflint0 has not rented DVD 826918 CMD: RETURN 12345 fflint0 CMD: PRINT_DVDS ------------------------------------------------------------------ Available DVDs Number Discs Title ------- ----- -------------------------------------------- 012-345 2 Harry Potter and the Chamber of Secrets 423-644 1 Matrix: Reloaded 826-918 4 Lord of the Rings: The Fellowship of the Ring 759-203 1 Dumbo ------------------------------------------------------------------ CMD: PRINT_CUSTOMERS ------------------------------------------------------------------ Current Customers Name: Fred Flintstone Card: 1234-1234-5678-5678 Username: fflint0 Address: 123 Bedrock LN Apt. 7 Rock Vegas NV 12345 Rented DVDs: 032-145 1 Pi 928-173 1 Hitchhiker's Guide to the Galaxy Name: Barney Rubble Card: 1234-5678-1234-5678 Username: brubblerubble Address: 123 Bedrock LN Apt. 8 Rock Vegas NV 12345 Rented DVDs: 927-833 3 Hunt for Red October ------------------------------------------------------------------ CMD: PRINT_USER fflint0 ------------------------------------------------------------------ Fred Flintstone (fflint0) has the following DVDs in queue: Number Discs Title ------- ----- -------------------------------------------- 759-203 1 Dumbo ------------------------------------------------------------------

Free Advice and Information

  1. Implement the new/modified functionality first. Then add overloaded operators, WITHOUT dynamic memory. Save a copy of this version of your project. Then, later, go back and actually modify your project to support dynamic memory.
  2. Hopefully you figured out in the last assignment that setfill() and setw() can be helpful - you will have need of them again.
  3. 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.
  4. 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; you must modify the makefile provided to account for these new files.
  5. Your program must provide adequate error checking as described above.
  6. 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.
  7. Review the class notes on the different methods of passing parameters. Each is best for a different situation.
  8. Be sure your function header comments list the pre- and post-conditions and handle each pre-condition that is not met.
  9. Your program will be tested with a variety of conditions.
  10. Use incremental development. Add ~5 lines, save, compile, test. Use function/method stubs to develop a class incrementally.
  11. Expect to use/modify code from this project in project 3. Design and code accordingly.
  12. This project is approximately 450 lines of code (many of which can be copied from proj 1), not including file header comments or function header comments.... don't procrastinate.

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 provided to you for project 1 and modify it appropriately. If you don't change the names of the files (much) from project 1, 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.

UPDATED
Grading - Your makefile must provide a rule that forces the use of the /usr/local/bin/g++ compiler for every .cpp file that you have as part of your project. You will have 5 pts deducted for "Makefile errors" if your makefile does not use the /usr/local/bin/g++ with -Wall and -ansi flags for EVERY .cpp file that you have included.


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: Friday, 04-Nov-2005 14:17:45 EST