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

CMSC 202 Fall 2005
Project 4

Netflux - "Many Shapes" in an Internet-based Movie Rental

Assigned November 7, 2005
Design Due 11:59pm on Sunday, November 13, 2005
Program Due 11:59pm on Sunday, November 27, 2005
Updates
  • 11/16 - Updates Utility.o, .h, and .cpp to include PRINT_LOG command
  • 11/16 - Added explicit listing of optional commands in the command list
  • 11/09 - Utility.o, .h, and .cpp posted in the normal location
  • 11/08 - DUE DATE error - corrected, note, design is still due in 1 week

Objectives


Project Description

In this fourth phase of the project you will be experimenting with inheritance and polymorphism within your application.

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

PRINT_SORTED_CUSTOMERS

PRINT_LOG

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

Basic Functionality

Customers who rent DVDs are essentially the same as in previous projects. There are multiple customers allowed in the system. Extensions to the representation of a Customer are described in the next section.

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

Polymorphic Functionality

There are now three different kinds of customers in the Rental System. Your project must use Inheritance and Polymorphism to implement a Customer class Hierarchy. Each kind of Customer has a unique cost associated with renting their DVDs as well as a unique limit to the number of DVDs that they can rent. Customers may not change types - once added to the system, they will remain the same type of Customer. Your Customer class hierarchy should look essentially like this:

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

Polymorphism

In order to make polymorphism work for this project you will have to implement all instances of Customer objects as dynamic memory. While you need not implement RentalSystems and DVDs as dynamic - if you got it working in Project 3, then you should leave it.

You are required to create at least one virtual or pure virtual method for use in your Customer classes. You may choose whether the method is pure or not, but your selection should be reasonable and should represent good OO design principles. You should place all other methods or data members required for use by the different Customer classes at appropriate levels of the hierarchy.

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, Utility.cpp and Utility.h in the following location:

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

The one public method of the Utility class is:

static bool GetCommand(istream& sin, vector& command);
The GetCommand method makes the following guarantees: 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

In order to be considered for the extra credit, you must submit a README file to the graders describing what you did.

Log File - 10 pts

In many systems, we want to be able to track what events occured on a per-customer basis. In order to support this functionality, you must implement a class to support a log for each customer. Each log is simply a record of transactions for that particular customer. You may print these to the screen in any logical method; however, it should be tabularly structured.

All commands that have been processed during this SINGLE run of your program should be recorded in a log. Obviously PRINT commands and OPEN commands will not be logged. However, QUEUE, RENT, and RETURN commands should be logged.

The new PRINT_LOG command supports this functionality.

Customer Search - 10 pts

As our system gets larger, searching for Customers will become time intensive. Since this is one of the most common actions in our system (i.e. the Customer must be found for most commands in the system), we want to optimize the search for a Customer.

For this 10 pts of extra credit, you must implement a more optimal search technique through your Customer collection. You can implement any search technique that works in O(log(N)) time or better. This means that on average, there are less than or equal to log(N) comparisons needed to find a Customer.

There are many acceptable stategies, some of the easiest would be to store a sorted version of the Customer collection and then perform a Binary search on the collection. However, not all strategies require a sorted collection. For example, storing all of your Customers in a programmer-defined Hash Table would be another alternative (although more complicated). You are encouraged to scour the text and internet for alternatives to these strategies if you are looking for something in-between. However, you MUST implement the strategy that you choose from scratch, you may not use STL classes or other built-in functions to perform the search for you (i.e. you can't use the STL hash-table or map to search for your customers).

The PRINT_CUSTOMERS command must continue to print the Customers in the order they were originally inserted into the system.

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 command keywords are all uppercase.

Valid commands for the system are as follows:

Command File Error Checking

Sample Command File

Commands that have been tested and described in previous projects have been left off of this example to eliminate clutter. However, your program must still support the complete functionality of the system as described above. OPEN stock.txt CUSTOMER Fred Flintstone fflint0 1234123456785678 BASIC 123 Bedrock LN Apt. 7 Rock Vegas NV 12345 CUSTOMER Barney Rubble brubblerubble 1234567812345678 EXTENDED 123 Bedrock LN Apt. 8 Rock Vegas NV 12345 CUSTOMER Betty Rubble blueBetty 1234567812345678 PREMIUM 123 Bedrock LN Apt. 8 Rock Vegas NV 12345 QUEUE 12345 fflint0 QUEUE 423644 fflint0 QUEUE 826918 fflint0 RENT fflint0 RETURN 12345 fflint0 RETURN 423644 fflint0 RETURN 826918 fflint0 QUEUE 12345 brubblerubble QUEUE 423644 brubblerubble RENT brubblerubble RETURN 12345 brubblerubble RETURN 423644 brubblerubble QUEUE 12345 blueBetty QUEUE 423644 blueBetty RENT blueBetty RETURN 12345 blueBetty RETURN 423644 blueBetty

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. The customer type has been added to the rental receipt. Also notice the representation of the "flat fee" for the appropriate Customer classes. 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 BASIC CMD: 123 Bedrock LN Apt. 7 CMD: Rock Vegas NV 12345 CMD: CUSTOMER Barney Rubble brubblerubble 1234567812345678 EXTENDED CMD: 123 Bedrock LN Apt. 8 CMD: Rock Vegas NV 12345 CMD: CUSTOMER Betty Rubble blueBetty 1234567812345678 PREMIUM CMD: 123 Bedrock LN Apt. 8 CMD: Rock Vegas NV 12345 CMD: QUEUE 12345 fflint0 CMD: QUEUE 423644 fflint0 CMD: QUEUE 826918 fflint0 CMD: RENT fflint0 ------------------------------------------------------------------ RENTAL RECEIPT --------------------- Customer Information --------------------- Name: Fred Flintstone Card: 1234-1234-5678-5678 Username: fflint0 Type: BASIC 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 423-644 1 Matrix: Reloaded 826-918 4 Lord of the Rings: The Fellowship of the Ring --------------------- Charges Detail --------------------- DVD Discs Per Disc Subtotal -------- -------- -------- -------- 012-345 2 $ .99 $ 1.98 423-644 1 $ .99 $ .99 826-918 4 $ .99 $ 3.96 -------- TOTAL $ 6.93 ------------------------------------------------------------------ CMD: RETURN 12345 fflint0 CMD: RETURN 423644 fflint0 CMD: RETURN 826918 fflint0 CMD: QUEUE 12345 brubblerubble CMD: QUEUE 423644 brubblerubble CMD: RENT brubblerubble ------------------------------------------------------------------ RENTAL RECEIPT --------------------- Customer Information --------------------- Name: Barney Rubble Card: 1234-5678-1234-5678 Username: brubblerubble Type: EXTENDED Address: 123 Bedrock LN Apt. 8 Rock Vegas NV 12345 --------------------- Rental Requests --------------------- Number Discs Title ------- ----- -------------------------------------------- 012-345 2 Harry Potter and the Chamber of Secrets 423-644 1 Matrix: Reloaded --------------------- Charges Detail --------------------- DVD Discs Per Disc Subtotal -------- -------- -------- -------- Flat Fee - $ 1.99 $ 1.99 012-345 2 $ .25 $ .50 423-644 1 $ .25 $ .25 -------- TOTAL $ 2.74 ------------------------------------------------------------------ CMD: RETURN 12345 brubblerubble CMD: RETURN 423644 brubblerubble CMD: QUEUE 12345 blueBetty CMD: QUEUE 423644 blueBetty CMD: RENT blueBetty ------------------------------------------------------------------ RENTAL RECEIPT --------------------- Customer Information --------------------- Name: Betty Rubble Card: 1234-5678-1234-5678 Username: blueBetty Type: PREMIUM Address: 123 Bedrock LN Apt. 8 Rock Vegas NV 12345 --------------------- Rental Requests --------------------- Number Discs Title ------- ----- -------------------------------------------- 012-345 2 Harry Potter and the Chamber of Secrets 423-644 1 Matrix: Reloaded --------------------- Charges Detail --------------------- DVD Discs Per Disc Subtotal -------- -------- -------- -------- Flat Fee - $ 3.99 $ 3.99 012-345 2 $ .00 $ .00 423-644 1 $ .00 $ .00 -------- TOTAL $ 3.99 ------------------------------------------------------------------ CMD: RETURN 12345 blueBetty CMD: RETURN 423644 blueBetty

Free Advice and Information

  1. Every attempt has been made to highlight the changes in BLUE so that you can quickly and easily see what functionality has changed. Remember to build the new classes slowly - use modular composition - create empty classes with no data members and no methods first, then add one piece at a time, compiling in between.
  2. 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.
  3. Functions called from main that are not part of any class are permitted. If you create new functions, their prototypes must be found in Proj4Aux.h and they must be implemented in Proj4Aux.cpp. You must modify the makefile provided to account for these new files.
  4. Your program must provide adequate error checking as described above.
  5. 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.
  6. Review the class notes on the different methods of passing parameters. Each is best for a different situation.
  7. Be sure your function header comments list the pre- and post-conditions and handle each pre-condition that is not met.
  8. Your program will be tested with a variety of conditions.
  9. Use incremental development. Add ~5 lines, save, compile, test. Use function/method stubs to develop a class incrementally.
  10. Expect to use/modify code from this project in the future. Design and code accordingly.
  11. Don't procrastinate.

Project Design Assignment

Your project design document for project 3 must be named p4design.txt. Be sure to read the
design specification carefully. Submit your design in the usual way: submit cs202 Proj4 p4design.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 Proj4 when they grade your project. This command must cause all .cpp files to be compiled and the executable named Proj4 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, Proj4, and backup files created by the editor. More information about these commands can be found at the bottom of the makefile.

Compiler:
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. The focus of this project is demonstrating understanding of inheritance within C++, so much of the Correctness points will be dedicated toward your design and implementation of the Inheritance hierarchy.

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 Proj4

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, 17-Nov-2005 17:43:38 EST