CS 157 Spring 2002 Assignment 9 Writing Classes (and testing) 100 points
Assigned: 04/11/2002
Due: 04/18/2002 at the start of class.
Pre-Lab (Do Before Lab): Think about the necessary structure and behavior for the object class. What data should be stored? What methods should there be? Bring an empty (or nearly empty) disk.
Main Assignment:
Imagine that your computer has radio capabilities (for local radio, not over the Internet) and that you are writing a program to enable a user to control the radio. We will be writing a simplified class definition for the radio, and writing a main function that demonstrates that the class works correctly. Before lab, think about the necessary structure and behavior of a radio. You may want to look at one and consider its controls – your program would be providing users a way of controlling the radio. To keep this relatively simple, think of a relatively simple radio. For instance, let’s limit the radio to just FM, so you don’t have to worry about switching bands. Make sure your main function demonstrates that all of the capabilities of the class work. It should, as with on Assignment 8, loop until the user decides to quit, meanwhile giving the user a choice of actions to take. Think of your main as interaction with the radio user finding out what they want. Main then gets those things to happen by calling the methods provided by the radio class itself. Since showing sample interaction would “give away” something I want you to determine for yourself, there is no sample interaction below.
(I
want you to determine what the radio needs to keep track of – the instance
variables – showing complete testing would tell what the instance variables
need to be). If you have questions or need feedback, talk to me in lab – but
plan first!
Hand in:
Miscellaneous:
·
You will need the SavitchIn.java file (still obtainable
from my WWW page - or from previous
weeks).
·
You can use dialog boxes if you prefer, but make sure
it doesn’t get in your way.
·
Valid FM radio stations range from 88.1 to 107.9. Make
sure your radio isn’t trying to play an invalid station.
·
MAKE SURE YOUR
PROGRAM WORKS! (i.e. more than just removing compile errors).
·
Put YOUR NAME, and
e-mail address in comments at the beginning of each file.
·
Remember: Indentation, meaningful variable names, and
meaningful comments. Weaknesses in any of these could result in points off. You MUST include comments that explain your
program in order to get full credit. EACH method must have comments
appropriate for javadoc.