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

CMSC 202 Fall 2003
Project 5

Video Store

Assigned Monday Nov 24, 2003
Design Due None -- Happy Thanksgiving
Program Due Sunday Dec 7, 2003 11:59pm
Updates 25 Nov 2003
After careful consultation and deliberation, R & F Video Stores, Inc., has realized that operator<< for the Patron class is required. Seems that it's used in the Proj5.cpp that was given to you for initial testing

Also, the term "const version" of SList::operator[](int i) has been clarified. See the SList class definition

Also, the order of the parameters of VideoStore::PrintSuggestedMovies() has been changed because the ostream parameter has a default value. The correct prototype is void PrintSuggestedMovies( const Patron& patron, ostream& out = cout)
A new version of Proj5.cpp has been placed in Mr. F's public directory.

24 Nov 2003
The prototype of SList's operator[] return a reference and be T& operator[] (int i). The original description returned T by value, not by reference.


Objectives


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.

  1. No friends allowed
  2. 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.
  3. You may use the sort() method from the STL, but no STL methods or classes other than string and vector may be used.
  4. You may use any method supported by the vector class.
  5. 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.
  1. A default constructor
  2. int Size(void) - returns the number of elements in the list
  3. void Print(ostream& out = cout) - prints the elements of the list one per line to the designated ostream
  4. 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.
  5. 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.
  6. void Remove(const T& item) - removes the item from the list. If the item is not in the list, no action is taken.
  7. 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
  8. 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.
  1. a default constructor if needed
  2. Movie( const string& title, const string& director, const string& star, const string& genre, RATING rating) - an alternative constructor
  3. 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
  4. 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.
  5. bool operator<( const Movie& rhs) -- required for sorting; compares the titles
  6. bool operator==( const Movie& rhs) -- compares all data fields
  7. const string& GetGenre(void) -- an accessor that returns the genre
  8. 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.
  9. 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.

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.
  1. a default constructor if needed
  2. Patron( const string& firstname, const string& lastname, int age, int patronId) - an alternative constructor
  3. const SList<string> GetInterests(void) - an accessor that returns the list of the Patron's interests
  4. int GetId(void) - an accessor that returns the Patron's id number
  5. void AddInterest( const string& areaOfInterest) adds a area of interest to the patron's list of interests
  6. 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
  7. 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.
  8. bool operator<( const Patron& rhs) - compares patrons by last name, then first name
  9. bool operator==( const Patron& rhs) - compares all data fields
  10. string GetName(void) - returns the concatentation of the first name and the last name separated by a space
  11. int GetAge(void) - an accessor that returns the age
  12. 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.
  1. A default constructor
  2. 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.
  3. void RemoveMovie(const Movie&) - removes the movie from the inventory. If the movie is not in the inventory, no action is taken.
  4. 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.
  5. void RemovePatron(const Patron&) - removes the patron from the mailing list. If the patron is not on the mailing list, no action is taken.
  6. 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.
  7. 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.
  8. 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.
  9. 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

  1. 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.
  2. 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

  3. 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

  4. 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.
  5. 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.

Sample Output

This sample output was created from Proj5.cpp found in Mr. F's public directory. It is a short test of the basic functionality. It is not a complete test. Any public method of any class may be tested when your project is graded. linux3[115]% Proj5 Movie4 ------ Title : A Little Kiss Director: me Starring: you Rating : XXX Genre : love Patron 2 -------- Name: bob smith Age : 44 Interests: love The Store --------- Movies: ------- Title Director Starring Rated Genre --------------- --------------- --------------- ----- -------------- A Little Kiss me you XXX love Guns A-Blazin clint clint PG13 western Hello World howard jane G love my movie bob mary G sci fi Patrons: -------- Last First Age Interests --------------- --------------- --- --------------- okeefe sam 22 smith bob 44 love smith mary 43 sci fi western Suggested movies for bob smith ---------------- Title : A Little Kiss Director: me Starring: you Rating : XXX Genre : love Title : Hello World Director: howard Starring: jane Rating : G Genre : love Patrons after removing bob smith -------------------------------- Patrons: -------- Last First Age Interests --------------- --------------- --- --------------- okeefe sam 22 smith mary 43 sci fi western ------------------------------------- Exception: Trying to add patron twice ------------------------------------- Name: mary smith Age : 43 Interests: sci fi western

Free Advice and Notes and Information

  1. Mr. F's public directory for this project is /afs/umbc.edu/users/d/e/dennis/pub/CMSC202/p5
  2. Implement the SList class first and thoroughly test it with a list of ints and/or list of strings
  3. Implement each class separately and test it.
  4. There is no inheritance in this project.
  5. There is no need to implement the copy constructor or assignement operator for your classes.
  6. Movie genre and patron interests are case sensitive.
  7. Since main( ) doesn't know that your classes use an SList to hold the data, it won't be catching any exceptions thrown by SList. It will only catch exceptions thrown by classes it uses (VideoStore, Movie and Patron).
  8. Start with Mr. F's Proj5.cpp and expand it to complete your testing.
  9. Be sure to note what part of the sample output is from main() and which is the responsibility of your classes.
  10. operator<< is NOT a member function of your class and CANNOT be a friend.

Project Design Assignment

There is no design assignment for this project -- Happy Thanksgiving!

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.

15% - Coding Standards

Your code adheres to the
CMSC 202 coding standards as discussed and reviewed in class.

Project Submission

For this project, you will create and submit the following files
  1. Movie.h and Movie.cpp
  2. Patron.h and Patron.cpp
  3. VideoStore.h and VideoStore.cpp
  4. SList.h and SList.cpp
  5. your makefile
  6. you may submit Proj5.cpp so that you can use submitmake and submitrun, but it will be deleted and not used by the graders
To submit your files, use the usual command submit cs202 Proj5 <list of files> The order in which the files are listed doesn't matter and not all files must be submitted at the same time. However, you must make sure that all files necessary to compile your project (using the makefile) are submitted before the project deadline.

You can check to see what files you have submitted by typing

submitls cs202 Proj5

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: Monday, 08-Dec-2003 11:01:44 EST