CS 630 - Computing Fundamentals I - Summer 2004
Project
Loyola College >
Department of Computer Science >
CS 630 >
Project
Due
Wednesday, July 28th at the beginning of class.
Projects will be penalized 20% for each day after the due date.
Projects will not be accepted more than four days late.
Objectives
- to create and use classes
- to use named constants
- to use conditional statements
- to use loops
Introduction
Imagine Tivo is developing its next generation product which will use profiles of individual family members to determine which shows to record. We will develop a class to represent a viewer profile. One instance of this class will contain all the information Tivo associates with a particular person. There will be fields for the viewer's name, age, gender, show preference, maximum number of hours that Tivo can record for that person, the number of hours that have been recorded, and an array that stores the ids of the shows that have been recorded. No person can record over 100 shows at a time. (We will assume that equal length programs take up the same amount of space on the hard drive.)
This class will also have several methods that will record and erase shows based on the profile, and other methods that will access the information stored in the profile.
A sample profile might look like:
- Name: Dad
- Age: 48
- Gender: male
- Show Preference: sports
- Maximum hours: 10
- Hours used: 3 (3 episodes of Sports Center)
Since we are developing a "Tivo2" prototype, there will be some limitations to our software. First, we will deal only with a subset of genres: comedy, reality, sci fi, soaps, and sports. Second, we will record shows based on the viewer's preference and demographic information only. We will use the following demographic rules:
- People under 30 watch comedy
- People between the age of 15 and 40 watch reality TV
- Sci fi is watched by men ages 12 to 25
- Soaps are watched by women over the age of 15
- Sports are watched by men over the age of 18
In our system each show will be identified by a unique 12 digit number. The first number will indicate the rating, the second the genre, numbers 3 through 6 will be the number of minutes the show runs, and the final six numbers indicate the unique show id.
Both Rating and Genres will have associated numeric values, which are listed in the following tables. Shows can run for a maximum of 9999 minutes, and for our purposes the six digit unique id can be generated randomly.
Rating Table
|
Genre Table
| Comedy | 0 |
| Reality | 1 |
| Sci Fi | 2 |
| Soaps | 3 |
| Sports | 4 |
|
Using the above information a show number of 320060388474 would indicate that show 388474 is a Science Fiction show rated PG-13 which runs for 60 minutes.
Ratings will be used to determine if a family member can record a particular show. Shows rated NR and G can be recorded by members of all ages. Shows with a rating of PG-13 can only be recorded by those 13 and older, and shows with a rating of R can only be recorded by those 17 years and older.
Assignment
Write a class called Tivo2. This class should have at least
the following attributes:
- fields as described above. You may add other fields as necessary, but make sure they contain class information and not method information.
- a constructor to create a new profile with the signature
Tivo2(String name, int age, char gender, int favoriteGenre) where gender will be the character 'F' for female and 'M' for male, and favoriteGenre will be an integer from the Genre Table above. The default number of hours recorded for each profile is 10 hours
- another constructor
Tivo2(String name, int age, char gender, int favoriteGenre, int maxHours)
will create a profile that can record up to the number of hours specified in maxHours
- a method isUnder13 that returns true if the family member is under 13 years old and false otherwise
- a method isUnder17 that returns true if the family member is under 17 years old and false otherwise
- a method isFemale that returns true if the family member is female and false otherwise
- a method getFavoriteGenre that returns the viewer's favorite genre
- a method setFavoriteGenre that changes the viewer's favorite genre to the one specified
- a method celebrateBirthday that increments the viewer's age by one year
- a method recordShow that takes a show number and records the show if and only if the viewer has sufficient space to store the show (in terms of time and number of shows recorded), and if the user has permission to view the show (based on its rating). This method should return true if the show is recorded and false otherwise. (Update all necessary class variables when you record a show.)
- a method autoRecordShow that takes a show number and records the show if the genre is suited to the viewer based on preferences or demographics, the user has sufficient space to store the show, and if the user has permission to view the show based on its rating. This method should return turn if the show is recorded and otherwise false.
- a method clearShow that takes a show number, determines if the show has been recorded and removes the show and frees the space associated with the show.
- named constants as appropriate
- other private methods to reduce redundancy in the code. Any computation that has to be performed for multiple methods should be written in its own method.
You should also write a test driver to test your methods thoroughly.
Assume that all Show Ids are strings that consist of twelve numbers. You should use the substr method to isolate the part of the string you want and than call atoi(sub.c_str()) to get the integer value.
Grading
- 60% Execution. Partial credit will be granted depending on how
much progress you made towards the correct result.
- 20% Design. The design score is based on how easy it is to
follow the logic of your code, how well you avoided repetitive code,
and how easy it would be to change your code if certain specifications
changed. Avoid dependencies in your code where you require that one method is call before another one.
- 10% Testing. The testing score is based on how thoroughly you
test your code. Even if your Tivo2 class
functions perfectly, you will get a 0 for testing if you do not
write a test driver. Incremental testing may help. After writing a method, add code to test it, and verify that it works correctly before going on to the next method.
- 10% Style. Style includes comments, indentation, and choice of
variable and method names.
- Substantial progress must be made towards correct execution to
earn the points for design and style.
Submissions
Submit the source code for your Tivo2 class
and your test driver. Turn in hard copies of your code and the output produced by the test driver.
This project may take between 30 and 40 hours to complete.