CS 280 Spring 2009                          

Assignment 6 – Writing(Most of) a Class   

100 “Assignment” points

 

Assigned: 02/25/2009

Due: 03/19/2009 at the start of class  (after break)

 

Pre-Lab (Do Before Lab):  Bring materials – a USB for a take home copy. Download and unzip the code that I’m providing. Look at Javadoc documentation to try to understand the methods that I’m asking you to provide.

 

Main Assignment:

Imagine that you are writing some parts of a FM Radio Simulation program (Radio World).  We are still a bit away from being able to do the full job, so pay attention to what I’m asking for.  I have provided a class that controls a GUI AND the beginnings of a class called Radio. Your job is to complete the Radio class so that the GUI class can run the simulation. You should NOT have to change the GUI class to make it run (I am asking for slight changes; see miscellaneous below). The provided classes will be in a zip file on Blackboard, along with Javadoc documentation for the classes.  Part of the Javadoc is included below; as a quick introduction, you should create methods:

1.      Simple inspectors for all 3 instance variables (class data). Each should merely return the desired value. These can be generated by NetBeans, if desired.

2.      “Pseudo-Inspector” getOnString” that returns the String “ON” or “OFF” depending on the radio’s status.

3.      Controlled mutators for radio frequency  instance variable:

a.      Move it up a notch (by 0.2). Make sure that is doesn’t go above the maximum frequency

b.      Move it down a notch (by 0.2).  Make sure that is doesn’t go below the minimum frequency

4.      Controlled mutators for radio volume  instance variable:

a.      Move it up a notch (by 1). Make sure that is doesn’t go above the maximum volume (NO 11!)

b.      Move it down a notch (by 1).  Make sure that is doesn’t go below the minimum volume

5.      Controlled mutator to turn the radio off

6.      Controlled mutator to turn the radio on

7.      A toString method that turns a Radio into a reasonable String representation of the radio. See screen shot below showing the GUI’s use of my version of toString to display the current radio status.

 

Background Knowledge:

 

User Interface:

·         I have provided a basic user interface. You don’t need to mess with it, except …

·         DO add your name to mine in the label on the GUI form  

 

Miscellaneous Details:

o    Make sure you read the documentation on the Radio class.  It is provided as Javadoc documents, which are html files that can be found inside the project folder included in the zip. The GUI class uses many (not all) of the methods, and will have errors until you supply the methods.  

 


Good Programming Practices:

o    MAKE SURE YOUR PROGRAM WORKS! (i.e. gets correct results).  It must provide all of the requested capabilities AND provide them in the expected way.  don’t change my code to make your code work!  Check that the desired parameters and return types are provided).

·         Add YOUR NAME, e-mail address, and purpose of the program in comments at the beginning of the Radio class (the dateshould already be there – which is also a very good practice). The purpose should be what the program is supposed to do, not the learning goals.

·         Indent to show any structure of the program (The IDE usually does this well if you don’t go back and change things – probably not much to worry about on this basic of a program)

o    You MUST include some comments that expain your program in order to get full credit; including a javadoc comment for each method that you write!!. Any methods with any complexity should have additional comments as well.

 

Red Tape to Aid Grading:

·         Add  your name in the jlabel on the GUI form 

 

Hand in:

 

Do your own assignments !!!!  Work that is copied or done with somebody (when not assigned to a group) will be punished. If programs are copied, both students will receive a zero for the assignment. If significant sections of programs are copied, points will be taken off. Changing small aspects of a copied program does not make it not a copy. Asking another for help on a step or two in a many-step assignment is acceptable; looking at another person’s program is temptation for cheating; handing in a near duplicate program is cheating

 

Sample Interface:

 

Mostly provided. But the test button uses the toString method, and should produce something along the lines of::