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.
- Open a DVD stock file - instructs the system to open a particular stock
file.
- Add a new customer to the rental system -- self explanitory.
- Add a DVD to a customer's queue of DVDs not yet rented.
- Return a DVD -- Adds the DVD to the "in-stock" list of DVDs. If possible
rents a new DVD to the customer.
- Print a list of all DVDs -- DVD information is printed for all "in-stock"
DVDs
- Print a list of customers -- Customer information and list of rented DVDs
is printed
- 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:
- the DVD rental system
- a Customer
- a DVD
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:
- OPEN <filename>
Opens a DVD stock file
<filename> is the absolute or relative path to a stock file
- CUSTOMER <first name > <last name > <username>
<card number>
<address>
<city> <state> <zip code>
Adds a customer to the system. Note that the address is on the SECOND line of
the command and the city, state and zip are on the THIRD - obviously, your
program won't know that there is a second line or third line
until it looks at the first one.
<first name > and <last name > are words with no spaces and any
punctuation is valid
<username> is a word with no spaces and only letters, digits, and the
underscore are permitted
<card number> is a 16-digit number with no spaces
<address> a collection of words of printable characters
<city> a collection of words of printable characters
<state> one of the 2-letter state abbreviations, no spaces
<zip code> is a 5-digit number with no spaces, between 01000 and 99999
(CHANGED from Project 1)
- RETURN <dvd number> <number of discs> <title>
<username>
Updated! Returns the specified DVD for the customer.
Adds the DVD to the "in-stock" list. If possible, rents the customer a
DVD and prints a receipt. The DVD need not exist in the current system.
<dvd number> valid as above
<number of discs> 1-3 digit number with no spaces
<title> a collection of words of printable characters
<username> valid as above
- QUEUE <dvd number> <username>
Updated! Adds the specified DVD to the customer's queue of DVDs to be rented. If the
customer's maximum capacity of rentals is not yet met, the DVD is shipped
immediately and a receipt is printed. The DVD need not exist in the current
system.
<dvd number> valid as above
<username> valid as above
- PRINT <items>
Updated!
Prints either DVD or Customer data. If DVD: print all the DVD's in-stock.
If CUSTOMER: print rental history and customer info (not queue). If username -
print the customer's queue. Any DVD information that is unknown can be left
blank.
<items> is "DVD", "CUSTOMER", or an username
Command File Error Checking
- If the command file cannot be found, the system shall display an error
message and exit.
- If the stock file cannot be found, the system shall display an error
message and exit.
- If the stock file is empty, command processing shall continue, there are
no DVDs available (until someone returns one).
- If a command is incorrect in any way (format or content), it shall be
discarded and processing
of the command file shall continue. Must include an error message.
- If a command cannot be executed (like queueing a DVD for a non-existant
customer), a message shall be printed and processing of the command file
shall continue.
- Updated!
You must validate all data including numbers. We will not promise that
things like the zip code will have 5 characters or that the characters will
be digits. We also do not promise that all data will be included on a single
line of a command. For example, the username may be left off. You CAN assume
that each command will include the appropriate NUMBER of lines (1 for all but
CUSTOMER which has 3). Hint: Use getline.
- Names, addresses, and other "word" based items, unless
specifically limited - they may contain any printable character.
- Printable characters are defined as any character that can be typed on the
keyboard. You need not validate these characters at all.
- Updated!
When a customer returns a DVD, the first available DVD on their queue
shall be rented to them and removed from their queue. Customers may have a
DVD on their queue any number of times. Available DVDs are DVDs that are
"in-stock".
- If (from a queue or return command) the customer cannot be rented a DVD,
the system shall display an error and continue processing the command file.
The next time that customer returns or queues a DVD, their quota shall be
filled (again, only if possible).
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
- In keeping with course standards, main( ) will be implemented in a file
named Proj2.cpp.
- Prototypes for any helper functions called from main will be located in
Proj2Aux.h and the functions themselves implemented in Proj2Aux.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 Proj2.
- Your executable must be named Proj2.
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:
- Customer credit card numbers must be displayed in the form
1234-5678-9012-3456.
- All monetary values must be displayed with 2 decimal places.
- When displaying a list of DVDs or customers, data must be aligned in
columns.
- Lists of DVDs/customers shall be displayed in the order DVDs/customers
are added to the rental system.
- 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:
- The renter's first and last name total no more than 20 characters.
- The renter's username totals no more than 20 characters.
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 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.
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.