becker.xtras.radio
Class SampleTuner

java.lang.Object
  extended by becker.xtras.radio.Radio
      extended by becker.xtras.radio.SampleTuner
All Implemented Interfaces:
ITuner

public final class SampleTuner
extends Radio
implements ITuner

A class implementing ITuner, to be used to demonstrate the code students are to write to work with RadioGUI.

Author:
Byron Weber Becker

Field Summary
 
Fields inherited from interface becker.xtras.radio.ITuner
NUM_PRESETS
 
Constructor Summary
SampleTuner(double low, double high, double freqChange)
           
 
Method Summary
 void addView(IView aView)
          Add a view (graphical user interface) to the tuner.
 void recallFrequency(int button)
          Recall the frequency associated with a given preset button by a previous call to ITuner.rememberFrequency(int).
 void rememberFrequency(int button)
          Remember the current frequency so that it can be later recalled with ITuner.recallFrequency(int).
 void seekDown()
          Move the frequency down until a station is found with a signal strength of at least 0.5.
 void seekUp()
          Move the frequency up until a station is found with a signal strength of at least 0.5.
 void setFrequency(double freq)
          Set this radio's current frequency.
 void tuneDown()
          Move the frequency one step down, unless the frequency is already at the lowest value for this band.
 void tuneUp()
          Move the frequency one step up, unless the frequency is already at the highest value for this band.
 
Methods inherited from class becker.xtras.radio.Radio
getFrequency, getSignalStrength
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface becker.xtras.radio.ITuner
getFrequency, getSignalStrength
 

Constructor Detail

SampleTuner

public SampleTuner(double low,
                   double high,
                   double freqChange)
Method Detail

tuneUp

public void tuneUp()
Description copied from interface: ITuner
Move the frequency one step up, unless the frequency is already at the highest value for this band. In that case, set it to the lowest frequency for this band.

Specified by:
tuneUp in interface ITuner

tuneDown

public void tuneDown()
Description copied from interface: ITuner
Move the frequency one step down, unless the frequency is already at the lowest value for this band. In that case, set it to the highest frequency for this band.

Specified by:
tuneDown in interface ITuner

seekUp

public void seekUp()
Description copied from interface: ITuner
Move the frequency up until a station is found with a signal strength of at least 0.5. If the highest frequency for this band is reached, continue the search with the band's lowest frequency.

Specified by:
seekUp in interface ITuner

seekDown

public void seekDown()
Description copied from interface: ITuner
Move the frequency down until a station is found with a signal strength of at least 0.5. If the lowest frequency for this band is reached, continue the search with the band's highest frequency.

Specified by:
seekDown in interface ITuner

rememberFrequency

public void rememberFrequency(int button)
Description copied from interface: ITuner
Remember the current frequency so that it can be later recalled with ITuner.recallFrequency(int). There are a possible NUM_PRESETS remembered frequencies, each assigned to a button in the user interface.

Specified by:
rememberFrequency in interface ITuner
Parameters:
button - The number of a preset frequency button. Between 1 and NUM_PRESETS, inclusive.

recallFrequency

public void recallFrequency(int button)
Description copied from interface: ITuner
Recall the frequency associated with a given preset button by a previous call to ITuner.rememberFrequency(int). Set the recalled frequency to be the current frequency. There are a possible NUM_PRESETS remembered frequencies, each assigned to a button in the user interface.

Specified by:
recallFrequency in interface ITuner
Parameters:
button - The number of a preset frequency button. Between 1 and NUM_PRESETS, inclusive.

setFrequency

public void setFrequency(double freq)
Description copied from class: Radio
Set this radio's current frequency.

Overrides:
setFrequency in class Radio
Parameters:
freq - The new frequency for this radio.

addView

public void addView(IView aView)
Description copied from interface: ITuner
Add a view (graphical user interface) to the tuner. The view's updateView method must be called each time the tuner's state changes.

Specified by:
addView in interface ITuner