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

CMSC 202 Fall 2005
Project 2

Netflux - a "Classy" Internet-based Movie Rental

Assigned September 30, 2005
Design Due 11:59pm on October 7, 2005
Program Due 11:59pm on October 14, 2005
Updates Sept. 30 - Multiple DVD information was added.
Oct. 2 - Customer rental maximum added.
Oct. 2 - RETURN command example corrected.
Oct. 5 - Command File example fixed to match Output Example.
Oct. 5 - Output Example corrected.
Oct. 11 - DVD Rental System updated.
Oct. 11 - RETURN command description clarified.
Oct. 11 - QUEUE command description clarified.
Oct. 11 - Command File Error Checking clarified.
Oct. 13 - Command File Error Checking clarified...again.
Oct. 13 - PRINT command clarified.

Objectives


Project Description

For the second phase of your system development, you will be modifying your code to include the use of classes in order to promote reusability and extendability in the future. You will also extend the system to support a command file that will define the tasks the system is to perform. Your system will continue to support the functionality introduced in Phase 1, but will also support multiple customers and the ability to rent multiple DVDs.

The DVD rental system Updated!

The DVD rental system must maintain information about each DVD the company owns, each customer who can rent a DVD, and information about which DVDs are currently rented. The basic functional requirements of the DVD rental system are detailed below.
  1. Open a DVD stock file - instructs the system to open a particular stock file.
  2. Add a new customer to the rental system -- self explanitory.
  3. Add a DVD to a customer's queue of DVDs not yet rented.
  4. Return a DVD -- Adds the DVD to the "in-stock" list of DVDs. If possible rents a new DVD to the customer.
  5. Print a list of all DVDs -- DVD information is printed for all "in-stock" DVDs
  6. Print a list of customers -- Customer information and list of rented DVDs is printed
  7. Print the queue for a particular customer

Customers

Customers who rent DVDs are essentially the same as in Project 1. However, now, there are multiple customers allowed in the system. Each customer also has a queue of DVDs they would like to rent next. Each customer is still charged $0.99 per disc to rent a DVD. Customers are uniquely identified by their username. No two customers are allowed to have the same username. NEW! Customers are limited to a MAXIMUM of 3 rentals at a time.

DVDs

DVDs are essentially the same as described in Project 1. They are identified by their DVD_NUMBER. If two DVDs share the same DVD_NUMBER, then there are two copies of that DVD. If a customer attempts to rent that DVD, they should only get to rent one of the copies - another customer may rent the other one.

Program Requirements

Your assignment is to write a program that simulates the DVD rental and shipping system described above. Your program will read commands from a command file and will respond accordingly by performing the requested action (adding a customer, returning a dvd, printing a list of customers, etc.). Your program will no longer prompt the user for any information, all instructions will be read from the command file.

Class Requirements

You will implement three C++ classes to model the following entities:

You may include any other classes that you feel are necessary or reasonable - these represent the minimum set of classes that you must use. Code from project 1 should be reusable in project 2. Remember when designing your class to use const member functions when appropriate as well as the different types of parameters and return values.

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.

Your program is required to print the command as read from the command file and then execute it appropriately.

Commands

Valid commands for the system are as follows:

Command File Error Checking

Sample Command File

Updated! OPEN stock.txt CUSTOMER Fred Flintstone fflint0 1234123456785678 123 Bedrock LN Apt. 7 Rock Vegas NV 12345 CUSTOMER Barney Rubble brubblerubble 1234567812345678 123 Bedrock LN Apt. 8 Rock Vegas NV 12345 QUEUE 12345 fflint0 PRINT brubblerubble QUEUE 12345 brubblerubble PRINT brubblerubble RETURN 826918 4 Lord of the Rings: The Fellowship of the Ring fflint0 PRINT DVD PRINT CUSTOMER PRINT fflint0

Stock File

The stock file is exactly as formatted in Project 1 EXCEPT that you must verify that the DVD_Number and NumberOfDiscs are actually digits. The DVD_Title can contain any printable characters. At this point in the projects, 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. Then, your system takes all those DVDs returned (via the command file) and may rent them to other customers. You DO NOT need to worry about updating the stock file (at this point).

Stock File Error Checking

Your program should validate the DVD Number and the Number of discs. If there is an error, the program should display an error message and disregard that DVD.

NEW! Multiple copies of DVDs are acceptable in the stock file. You may assume that the number of discs and title will be identical for duplicate DVDs - therefore need only store the first copy of that data. Duplicate DVDs will of course have the same DVD Number. If there are multiple copies of a DVD, multiple customers can rent that DVD.

Sample Stock File

Updated! 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

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 CMD: CUSTOMER Fred Flintstone fflint0 1234123456785678 123 Bedrock LN Apt. 7 Rock Vegas NV 12345 CMD: CUSTOMER Barney Rubble brubblerubble 1234567812345678 123 Bedrock LN Apt. 8 Rock Vegas NV 12345 CMD: QUEUE 12345 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 Returns --------------------- Number Discs Title ------- ----- -------------------------------------------- --------------------- Rental Requests --------------------- Number Discs Title ------- ----- -------------------------------------------- 012-345 2 Harry Potter and the Chamber of Secrets --------------------- Charges Detail --------------------- DVD Discs Per Disc Subtotal -------- -------- -------- -------- 012-345 2 $ .99 $ 1.98 -------- TOTAL $ 1.98 ------------------------------------------------------------------ CMD: PRINT brubblerubble ------------------------------------------------------------------ Barney Rubble (brubblerubble) has the following movies in queue: Number Discs Title ------- ----- -------------------------------------------- ------------------------------------------------------------------ CMD: QUEUE 12345 brubblerubble CMD: PRINT brubblerubble ------------------------------------------------------------------ Barney Rubble (brubblerubble) has the following movies in queue: Number Discs Title ------- ----- -------------------------------------------- 012-345 2 Harry Potter and the Chamber of Secrets ------------------------------------------------------------------ CMD: RETURN 826918 4 Lord of the Rings: The Fellowship of the Ring fflint0 CMD: PRINT DVD ------------------------------------------------------------------ Available DVDs Number Discs Title ------- ----- -------------------------------------------- 423-644 1 Matrix: Reloaded 826-918 4 Lord of the Rings: The Fellowship of the Ring 759-203 1 Dumbo 826-918 4 Lord of the Rings: The Fellowship of the Ring ------------------------------------------------------------------ CMD: PRINT CUSTOMER ------------------------------------------------------------------ Current Customers Name Username -------------------- -------------------- Fred Flintstone fflint0 012-345 2 Harry Potter and the Chamber of Secrets Barney Rubble brubblerubble (none) ------------------------------------------------------------------ CMD: PRINT fflint0 ------------------------------------------------------------------ Fred Flintstone (fflint0) has the following movies in queue: Number Discs Title ------- ----- -------------------------------------------- ------------------------------------------------------------------

Free Advice and Information

  1. You may find it handy to review the material on string streams for this assignment - they can be particularly handy in ripping apart lengthy commands! You may also consider using them to generalize your command-parsing algorithm - remember, if there were to be 100s of commands, would you want to write a function to handle each one???
  2. There are some functions like isalpha() and isdigit() that you might find helpful for this assignment...look them up.
  3. Hopefully you figured out in the last assignment that setfill() and setw() can be helpful - you will have need of them again.
  4. 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.
  5. Functions called from main that are not part of any class are permitted. If you create new functions, their prototypes must be found in Proj2Aux.h and they must be implemented in Proj2Aux.cpp; you must modify the makefile provided to account for these new files.
  6. Your program must provide adequate error checking as described above.
  7. 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.
  8. Review the class notes on the different methods of passing parameters. Each is best for a different situation.
  9. Be sure your function header comments list the pre- and post-conditions and handle each pre-condition that is not met.
  10. Your program will be tested with a variety of conditions.
  11. Use incremental development. Add ~5 lines, save, compile, test. Use function/method stubs to develop a class incrementally.
  12. Expect to use/modify code from this project in project 3. Design and code accordingly.
  13. 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 2 must be named p2design.txt. Be sure to read the
design specification carefully. Submit your design in the usual way: submit cs202 Proj2 p2design.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 Proj2 when they grade your project. This command must cause all .cpp files to be compiled and the executable named Proj2 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, Proj2, 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 Proj2

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: Thursday, 13-Oct-2005 18:42:14 EDT