General Project Description
You have been "hired" to implement the NetFlux - Internet-based DVD Rental
system. The client (your instructor) has requested the system be completed in
five phases (projects) and each phase should fully and correctly implement
the required functionality. At the end of each phase, the client will
evaluate your work and provide suggestions for improvement as well as
a complete list of requirements
for the next phase. You will want to be sure that your system implements
the required functionality for each phase before submitting it for evaluation.
The final NetFlux system will support a large group of customers, a variety of
rental objects (ex: DVDs, books, CDs, etc.), as well as different kinds of
customer accounts. The primary responsibility of the system will be to
process customer requests, charge accounts, manage stock, and summarize
daily shipping and sales. Your implementation will gradually improve over the
semester to include all of these requirements. Remember - any and all of these
requirements may change or expand throughout the semester - be sure to write
maintainable, modifiable code!
Project Description
For the first phase of the project, your client requires that you implement
the following components of functionality:
- Read in a list of stocked DVDs from a file
- Retrieve a single customer's information from a user
- Rent one DVD to that customer
- Calculate the customer's rental fee
- Print a receipt for the customer
Stock File
The file that details the DVDs that are stocked by the company is formatted
as follows:
- DVD_Number - a positive integer between 1 and 999999, inclusive
- NumberOfDiscs - a positive integer between 1 and 100, inclusive
- DVD_Title - a collection of (mostly) English words
The system must verify data from the file immediately and discard the entire
entry if invalid data are supplied. DO NOT prompt for confirmation, simply
print an error message, discard the entry, and continue processing the file.
You can assume that the data will be of the proper type (ex: if an integer is
specified, we will only test your program by giving it integers). The name
for this file will be supplied by the user (check the User Interaction part).
Here is an example of a DVD stock file there are 4 DVDs in stock:
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
User Interaction
The system is required to request the following data directly from the user in the FOLLOWING ORDER:
- Filename for DVD Stock File
- Renter's name - two words on same line separated by one or more spaces
- Renter's username - a single word, only letters, digits, and underscores
- Renter's credit card number - a positive integer between
10,000,000 and 99,999,999, inclusive (remember - integers will be entered WITHOUT
the commas!)
- Renter's street address - shipping address, words on one line
- Renter's city - one or more words on one line
- Renter's state abbreviation - two letters (
valid state
postal abbreviations) Updated!
- Renter's zip code - a positive integer between 10,000 and 99,999, inclusive
(remember - integers will be entered WITHOUT the commas!)
- DVD's number - the number of the DVD to rent (valid as above)
The system must verify data from the user immediately and re-prompt if invalid
data are supplied. Reprompt ONLY for the invalid data, DO NOT restart from the
renter's name. DO NOT abort your program. You can assume that the data will
be of the proper type (ex: if an integer is specified, we will only test your
program by giving it integers, however, the integer may be too large or too
small; ex: if a string/word is specified, we will give you characters, but
they may be invalid characters).
DVD Rental
The system will rent a single DVD (perhaps with multiple discs) to a single
customer. The rental cost must be calculated for the customer. Currently,
DVDs will be rented at $.99 per disc (ex: the Harry Potter movie listed above
would cost $1.98 to rent). A receipt for the rental should be displayed for
the user.
The customer receipt should look something like this:
------------------------------------------------------
RENTAL RECEIPT
------------------------------------------------------
---------------------
Customer Information
---------------------
Name: Fred Flintstone Card: 1234-5678
Username: f_flint
Address: 123 Street Address RD
A City, ST 12345
---------------------
Rental Requests
---------------------
Number: 012-345 Discs: 2
Title: Harry Potter and the Chamber of Secrets
---------------------
Charges Detail
---------------------
DVD Discs Per Disc Subtotal
-------- -------- -------- --------
012-345 2 $ .99 $ 1.98
--------
TOTAL $ 1.98
------------------------------------------------------
The receipt must contain the following information:
- Renter's name
- Renter's card number (formatted as: XXXX-XXXX; hint: use div and mod)
- Renter's username
- Renter's street address
- Renter's city, state and zip (formatted as: CITY, ST XXXXX)
- List of all of their rental requests (at this point, just one), listing
DVD number (formatted XXX-XXX, ex: 012-345), number of discs, and disc title
- List of all of their charges, detailing the DVD number, the
number of discs, cost per disc, subtotal for that line and total for
entire order
The receipt MUST be "tabular" (i.e. vertically aligned data) - failure
to do so will be penalized. DO NOT spend too much time trying to make
your output exactly like the above output - it is ONLY a guide. Similar
output with a tabular style will receive full credit.
Design and Implementation Requirements
Functions
This project is designed to give you ample opportunity to explore, experience,
and use functions with a variety of different styles of parameters. You MUST
use functions in this project whenever possible. If your main function is
longer than 25-50 lines or so - it is probably too long - you need to break
it apart. However, if your functions are all less than 5 lines, or several
look very similar, you may need to rethink/combine them.
- The proper use and implementation of functions is an important
part of this project (and your grade for this project). In particular,
- Your program must make adequate use of functions in keeping with
top-down design principles.
- The names of the functions are left to you, but poor naming
will lead to losing points.
- Parameters must be passed to functions using the appropriate
technique (by value or by reference).
- The proper use
of const and default values with parameters are also necessary.
- Values must be returned from functions appropriately.
-
All functions called from main() must be implemented in
a separate file named Proj1Aux.cpp. The prototypes for these
functions must be found in a file named Proj1Aux.h.
- Be sure your function header comments list the pre- and post-conditions
and handle each pre-condition that is not met.
- Review the class notes on the different methods of passing
parameters. Each is best for a different situation.
Data
- You MUST use an efficient algorithm to format the Credit Card number and
DVD Number (do NOT use a series of if-statements). HINT: Think about how you
can use division and modulus to accomplish this in ONE or TWO lines of code!
- Your program must use const variables rather than "magic numbers"
or "magic strings".
- Although not required, you may find the use of one or more
structs helpful in organizing your data.
- Because your user will input strings that may contain spaces, the
use of the ignore( ) function may be necessary. See the class notes
on strings.
- Your program must provide adequate error checking of user input.
- Your program will be tested with a variety of good and BAD inputs.
- Get your project working with good input first. Then go back and put
in the error checking and error handling.
General Tips
- Be sure to name your files as noted above,
otherwise, you will have to modify the makefile we provide.
- Because your program will be tested using Unix redirection, DO NOT prompt
for any input not specified in the project description.
- Use incremental development.
- This project is approximately 150 - 200 lines of code... don't
procrastinate.
- Ms Wortman's public directory for this project is
/afs/umbc.edu/users/d/a/dana3/pub/CMSC202/p1.
NEW! Error Handling
- Your program must validate the user's input so far as ensuring that it is
an acceptable value.
- If the DVD to rent does not exist, the rental receipt shall print a
message to that effect and the bill will be zero.
- If the DVD stock file does not exist, the user should be reprompted (i.e.
that filename is invalid) immediately.
- If the DVD stock file is EMPTY, then there is nothing in stock and the
system should act as if the DVD did not exist.
Project Design Assignment
Your project design document for project 1 must be named p1design.txt.
Be sure to read the
Project Makefile
The "make" utility is used to help control projects with large numbers of files.
It consists of targets, rules, and dependencies. You will be learning about
make files in discussion. For this project, the
makefile will be provided for
you. You will be responsible for providing makefiles for all future projects.
Copy the file makefile from Ms. Wortman's public directory to your
directory.
When you want to compile and link your program, simply type
the command make or make Proj1
at the Linux prompt.
This will compile all necessary .cpp files and create the
executable named Proj1.
The make utility can also be used for compiling a single program without linking.
For example, to compile Proj1.cpp, type make Proj1.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 files, Proj1 executable 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.
- Your project produces all required output.
- The output produced is correct.
- The output is in an acceptable format.
- Your program follows good top-down design principles.
- All function parameters are passed using the appropriate method.
- const variables are used wherever appropriate.
- All unmet function pre-conditions are handled.
- Use of efficient method for formatting hyphenated numbers.
- All project requirements are met.
15% - Coding Standards
Your code adheres to the