CS1007
Fall 2001
Homework #7
due Wed 5 December 2001 12am (midnight)
THERE WILL BE NO EXTENSIONS!!!

last updated: Wed Nov 28 22:59:40 EST 2001
updated version which contains data file specification (see section 2)

the goal... This is your last homework assignment for cs1007 (yippee!). The goal is to put together many of the pieces we've learned this semester into one program. The description of this program (below) is a more general type of specification than you've had for your previous homeworks. You will have to make the design and implementation decisions yourself, though you can use examples from class on Tue Nov 27 and Thu Nov 29 to help you get started.

Note: As above, there will be no extensions on this assignment. The only exception is if you have a documented medical excuse.

the problem... You need to design and implement software for a virtual "TV manager". We can pretend that this is a device that is connected to your TV and controls who can watch what and for how long.

The television has cable, so it gets lots of channels -- but for this assignment, let's only worry about the following fifteen channels: ABC, AMC, CARTOON, CBS, CNN, CSPAN, DISNEY, FOX, HISTORY, NBC, NICK, PBS, PLAYBOY, TBS and TNT.

The TV is in a house shared by several people. Each person in the house is classified as either an adult or a child. Children are allowed to watch one hour of television each day. They are not allowed to watch PLAYBOY or CNN. Adults are allowed to watch as much TV as they want to, on any channel they want.

The program interfaces with a data file (i.e., a text file, like we discussed in class today, Tue Nov 27). The data file contains the names of each of the users (i.e., the people in the house), their classification (i.e., child or adult), and the number of hours of television they have watched so far each day.

The TV manager has a command line interface (which we'll discuss in class on Thu Nov 29) with several options:

P
prints the list of users and their usage
A
adds a new user to the list
R
removes a user from the list
W
processes a user's request to watch something
N
indicates the start of a new day
Q
quits the program

When a user enters option W, she should be asked to specify her name, the channel she wants to watch and how long she wants to watch that channel. The TV manager will either approve her selection and turn on the television, or it will disapprove her selection and refuse to turn on the TV. You can assume that if her choice is approved, she will watch the requested channel for the requested amount of time.

When a user enters option N, the program should reset the number of hours of television watched so far each day to 0, for all users.

As in class today, the program MUST begin by reading the data file into program variables. While the program is running, those program variables will be manipulated. When the user enters option Q, the program MUST write the values of the program variables to the data file.

1. design... the program. You MUST write a SHORT design document describing your approach to the program. This description MUST include the following:

Note: This design document will ONLY be submitted in hard copy. Do NOT submit this part electronically.

2. implement... the program. Your program MUST be a Java application. You can use as many class files as you need to, but the main() method MUST be contained in a file called hw7<yourCUNIXusername>.java, e.g., hw7eis2003.java. Don't forget to comment your code. Hint: your source code comments should be consistent with your design document!

You MUST use a standard format for the data file,, as follows:

3. submit... As usual, submit your program in two ways: electronically and hard copy.

You MUST submit all the necessary Java files for your implementation of this assignment. To do so, create a subdirectory containing ONLY these Java files and then run the submit script from this directory. The submit script should automatically pick up all the files (and should tell you so when asking for you to confirm the submission).
PLEASE Please please do NOT submit extraneous Java files -- only the current version of the ones we'll need to run your assignment.
PLEASE Please please do NOT submit your design document electronically.

The hardcopy must contain your design document followed by a listing of all your Java files. Due to recent departmental policy, there is no longer a box in the department office for submitting hardcopies... SO you MUST hand in your hardcopy by bringing it to class on THU DEC 6. This is the last class, and we will review for the final exam, so it would be a good idea not to skip this class anyway. No hardcopies will be accepted after 4pm EST Thu Dec 6 (otherwise you will lose 5 points for failing to submit a hardcopy on time).

Homeworks must be submitted electronically by 12 MIDNIGHT on Wed Dec 5; otherwise they will NOT BE ACCEPTED.