Project Description
Congratulations!!
As a result
of your successful completion of the banking system, R & F have awarded
you a similar contract for their new video rental business.
Phase I of the system will be a system that maintians the inventory of
movies and the mailing list of patrons who have joined "R & F Video".
As part of the monthly news letter, the system will suggest movies to
each patron, based on the patron's age and interests.
Class Descriptions
The class descriptions below must be followed exactly. You and the R & F
software team have agreed upon all class interfaces, so the R & F team expects
that your files, classes and their public methods will be named exactly as listed
below. Deviation from these agreed upon names will result in breach of contract
since your code will not link with the test code from R & F.
You and R & F have agreed on the following implementation rules. Failure to
follow these rules will result in a reduction of your compensation.
Also note that the data in the store is very sensitive. R & F expect that
you will implement all possible security measures to protect their data.
- No friends allowed
- No public methods other than those specified below are permitted
(you may create whatever private methods you deem necessary). These methods
were sufficient when the R & F staff designed the system. If you find
that other methods appear absolutely necessary,
you may solicit R & F for additional methods.
- You may use the sort() method from the STL, but no STL methods or classes
other than string and vector may be used.
- You may use any method supported by the vector class.
- All string data is limited to 15 characters in length. You need not
check for this condition.
The SList class template
At the heart of the system is a sorted list class. Since this class will
be used to contain data of various types, it will be implemented as
a template. The sorted list is implemented in the SList class. The SList
class is implemented in SList.cpp. Its interface is found in SList.h and described
below. For purposes of describing the interface, we'll assume the
template type parameter is named T. Data in the SList class is stored in a vector.
- A default constructor
- int Size(void) - returns the number of elements in the list
- void Print(ostream& out = cout)
- prints the elements of the list one per line to the designated ostream
- void Insert(const T& item) --
Inserts a new item into the list. A DuplicateItem exception
is thrown if an attempt is made to insert the same item more than once.
- int Find( const T& item) -- searches the list and returns
the index of the item if found. Returns -1 if the item is not in the list.
- void Remove(const T& item) -
removes the item from the list. If the item is not in the list, no action
is taken.
- T& operator[](int i)
-- retrieves the item at the specified subscript.
A NoSuchItem exception is thrown if the index is invalid for the list.
Note - you will probably need two versions of this method -- one that's
const and one that is not.
The list must be maintained in sorted order at all times since we have not provided
a public methodThe prototype for the const version is
const T& operator[](int i) const
- the overloaded operator<< that outputs all elements
of the list in sorted order.
The list must be maintained in sorted order at all times since we have not provided
a public method that can be used to sort the list. This is most easily
accomplished when a new item is inserted. You can write your own code to
do this (about 10 lines) or you may use the STL sort( ) function.
The sort( ) function requires a very little bit of knowldege about iterators
(we'll discuss those after Thanksgiving), but not much. To use sort( )
you must #include <algorithm>. A quick Google search will show you
how to sort a vector.
The Movies
A movie is modelled in the Movie class. Movie data consists
of a title, the director, the star, the genre and the rating.
The Movie class is
implemented in Movie.cpp and its interface is defined in Movie.h as described
below.
- a default constructor if needed
- Movie( const string& title, const string& director, const string& star,
const string& genre, RATING rating) - an alternative constructor
- void Print( ostream& out = cout) - prints a single
movie with the title, director, star, genre, rating output one a separate line
with an an appropriate label
Title : High Noon
Director: John Smith
Starring: Gary Cooper
Rating : G
Genre : Western
- void FormatTabular( ostream& out = cout )
Formats (not prints) the movie data on a single line. The data is formatted
in the order: title, director, star, rating, genre. Each of title, director,
star and genre is right justified in a field of 15 characters. Rating is
formatted in a field of 5 characters. There is a single space between each field.
- bool operator<( const Movie& rhs)
-- required for sorting; compares the titles
- bool operator==( const Movie& rhs)
-- compares all data fields
- const string& GetGenre(void) -- an accessor that returns the genre
- bool IsAppropriate(int age) -- returns true if a person of
the given age should see this movie, based on the movie's rating; returns false if not.
- overloaded operator<< which prints a single movie
as described in the Print() method above.
Movie Ratings
The Movie class' rating is an enumerated type named RATING
whose allowable values are G, PG13, N17 and XXX. See the text for
an explanation of defining and using an enumeration.
Use the strings "G", "PG13", "N17" and "XXX", to display a movie's rating.
The ratings are used to describe the appropriate age group for the movie.
- A "G" movie is suitable for all ages
- A "PG13" movie is suitable for anyone 13 years old or older
- A "N17" movie is suitable for anyone 17 years old or older
- A "XXX" movie is suitable for anyone 21 years old or older
The Patrons
A patron is a person who is allowed to rent movies from R & F.
A patron is modelled in the Patron class. The Patron
class has the following data fields - first name, last name, age, id number
and zero or more areas of interests. The Patron class is implemented in Patron.cpp.
It's interface is found in Patron.h and described below.
- a default constructor if needed
- Patron( const string& firstname, const string& lastname,
int age, int patronId) - an alternative constructor
- const SList<string> GetInterests(void) - an accessor that
returns the list of the Patron's interests
- int GetId(void) - an accessor that returns the Patron's id number
- void AddInterest( const string& areaOfInterest)
adds a area of interest to the patron's list of interests
- void Print(ostream& out = cout) - prints a patron's data
as shown below. All patron interests are printed on the same line.
Name: mary smith
Age : 43
Interests: sci fi western
- void FormatTabular(ostream& out = cout)
Formats (not prints) a parton's information on one line. Each string is
right justified in a field of 15 characters. Age is right justified in
a field of 3 characters. All fields are separated by a single space.
Data is printed in the order: last name, first name, age, list of interests.
- bool operator<( const Patron& rhs)
- compares patrons by last name, then first name
- bool operator==( const Patron& rhs) -
compares all data fields
- string GetName(void) - returns the concatentation of the first name
and the last name separated by a space
- int GetAge(void) - an accessor that returns the age
- overloaded operator<< that outputs a single patron as described in
the Print( ) method.
Since operator== compares all fields of a Patron it is
theoretically possible
that two Patrons can have the same id. R & F guarantee that their off-line
system that assigns ids to patrons will not assign the same id more than once,
although your code should work fine in either case.
The Video Store
The R & F video store is modelled with the VideoStore class. This class
encapsulates a sorted list of movies and a sorted list of patrons.
The VideoStore class is
implemented in VideoStore.cpp and its implemenation in VideoStore.h as
described below.
- A default constructor
- void AddMovie(const Movie&) - adds a movie to the store's inventory.
If the movie is already in the inventory, a DuplicateMovie
exception is thrown.
- void RemoveMovie(const Movie&) - removes the movie from
the inventory. If the movie is not in the inventory, no action is taken.
- void AddPatron(const Patron&) - adds a Patron to the store's
mailing list. If the Patron is already on the mailing list,
a DuplicatePatron exception is thrown.
- void RemovePatron(const Patron&) - removes the patron from
the mailing list. If the patron is not on the mailing list, no action is taken.
- void PrintMovies(ostream& out = cout) - prints the inventory
of movies in a tabular format with headings and one movie per line. See the
sample output below. Movies must be printed
in sorted order as specified by the Movie "less than" operator.
- void PrintPatrons(ostream& out = cout) - prints the mailing
list in a tabular format with headings and one patron per line. See the
sample output below. Patrons must be printed in
sorted order as specified by the Patron "less than" operator.
- void Print(ostream& out = cout) - prints both the mailing
list and inventory in table format as described above and seen in the
sample output below.
- void PrintSuggestedMovies(const Patron& patron, ostream& out = cout)
Prints movies appropriate for the patron based on the patron's age and
list of interests. A movie is printed if the age is appropriate for the
movie's rating and the movie's genre is found in the list of interests.
The movies are printed in the format specified by the Movie's Print() method.
If the patron is not in on the mailing list, a NoSuchPatron
exception is thrown.
Exceptions
In the discussion of the classes, some exceptional conditions were uncovered.
The following exception classes are required. Exceptions may be defined and
implemented with their associated classes as indicated below.
These exception classes can be defined in SList.h
- DuplicateItem - this exception is thrown by SList's Insert()
method when an attempt is made to insert an item already in the list. This class
is a trivial, empty class with no methods and no data.
- NoSuchItem - this exception is thrown by SList's operator[]
method when an attempt is made to access an item outside the bounds of the list.
This class is a trivial, empty class with no methods and no data.
This exception class can be defined in Movie.h and implemented in Movie.cpp
- DuplicateMovie - this exception is thrown when an attempt is made
to add a duplicate movie to the inventory. The constructors are left to you,
but this exception must store the Movie that was being trying to be added.
The accessor const Movie& GetMovie(void) must also be provided.
These exception classes can be defined in Patron.h and implemented in Patron.cpp
- DuplicatePatron - this exception is thrown when an attempt is
made to add a duplicate patron to the mailing list. The constructors are left to you,
but this exception must store the
Patron that was being trying to be added. The accessor
const Patron& GetPatron(void) must also be provided.
- NoSuchPatron - this exception is thrown when an attempt is
made to access information about a nonexistent Patron. The constructors are left to you,
but this exception must store the Patron that was being trying to be accessed.
The accessor const Patron& GetPatron(void) must also be provided.
Project Makefile
For this project, you will be responsible for providing your own makefile.
Typing "make" should compile and link all files for your project.
Your makefile should also support the commands "make clean" and "make cleanest".
If you start with the makefile for project 4, the changes for project 5 are
straightforward.
Grading
The grade for this project will be broken down as follows. A more detailed
breakdown will be provided in the grade form you recieve
with your project grade.
85% - Correctness
This list may not be comprehensive, but everything on this list will be
verified by the graders.
- All file and class names match the specification
- All function signatures match the specification
- All required output present
- All required output correct for various test cases
- Output presented in the format described
- Proper OO design and implementation
- All error conditions detected and exceptions thrown when appropriate
- NO FRIENDS allowed
15% - Coding Standards
Your code adheres to the