CS 201 - Computer Science I - Spring 2004
Project 2


Loyola College > Department of Computer Science > CS 201 > Projects > Project 2

Due

Monday, March 22th at 11:59pm. Projects will be penalized 20% for each day after the due date. Projects will not be accepted more than four days late.

Objectives

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, and the number of hours that have been recorded. (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:

Since we are developing a "Tivo2" prototype, there will be some limitations to our software. First, we will not keep track of the individual shows recorded, only their hours. Second, we will deal only with a subset of genres: comedy, reality, sci fi, soaps, and sports. Third, we will record shows based on the viewer's preference and demographic information only. We will use the following demographic rules:

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.

Number representation

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

NR 1
G 2
PG-13 3
R 4

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:

You should also write a test driver to test your methods thoroughly.

Hint: Show Ids must be of type long because an int cannot hold such a large number. Also when creating show ids for testing you will not be able to create an id with the following statement:
long id = 999999999999;
because java will first create an int and then turn it into a long. Instead you will need to use something like the following technique:
long id = (long)rgmin * 1000000 + uniqShowID;
where rgmin is the rating, genre, and running time and uniqShowID is the randomly assigned number for the show.

Grading

Submissions

Submit the source code (.java file) for your Tivo2 class and your test driver.