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:
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:
Your program MUST be a Java application.
You can use as many class files as you need to,
main() method MUST be contained in a file called
Don't forget to comment your code.
your source code comments should be consistent with your design document!
You MUST use a standard format for the data file,, as follows:
TIME <timestamp> USER <name> <classification> <hours-watched-today> USER <name> <classification> <hours-watched-today> . . . USER <name> <classification> <hours-watched-today>Assume that the timestamp is the time in seconds since Jan 1, 1970 -- i.e., the value returned by Date.getTime().
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
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.