CMPT 126 - Harbour Centre - Fall 2006
Home  
Assigned Readings  
Examples  
Labs  
Assignments  
References  
Gradebook  
 
 
  1. For this lab, you will create a class TV that keeps track of the state of a (simple) television. This television has only a channel tuner: no volume control, picture adjustment controls, etc.

    The TV class will be instantiated to create a TV object. Each TV object should have these methods:

    public TV() (constructor)
    The TV has been turned on for the first time: initialize the object, so that we are viewing channel 2.
    public TV(int ch) (constructor)
    The TV has been turned on, but we know what channel was being watched last time it was on: initialize the object, so that we are viewing given channel. *
    public void enterChannel(int ch)
    The user has entered the given channel on the remote control: switch to that channel. *
    public void pressChannelUp()
    The user has pressed the channel-up button on the remote control: increase the channel by one. *
    public void pressChannelDown()
    The user has pressed the channel-down button on the remote control: decrease the channel by one. *
    public int currentChannel()
    User has asked for the current channel: return the channel that the user is currently watching.
    public void prevChannel()
    User has pressed the previous channel button: flip back to the last channel that they were watching. If the TV was just turned on (no previous channel), nothing should happen.

    The user should be able to repeatedly press the previous channel button to flip back-and-forth between two channels.

    * This TV can only display channels 2-99. If the user tries to change to a channel outside of that range, your class should do something reasonable to keep the channel in the given range.

  2. Create a text file named time.txt. In it, indicate how long it took you to complete this lab exercise.

When you're done, create a ZIP file containing all of the files you created for this lab and submit it with the submission server.