In order to provide these capabilities, radio must retain some information with it, for example current state (on or off), current volume level, current channel.

engineering

Description

Problem Statement:

 

We know that radio is a very useful device. A radio should have the following capabilities:

 

1.  Turn the power on/off

2.  Channel Up

3.  Channel Down

4.  Volume Up

5.  Volume Down

 

In order to provide these capabilities, radio must retain some information with it, for example current state (on or off), current volume level, current channel.  When we have a radio and turning it ON will have its initial values of these state variables. This is the job of your class constructor.

 

You will need to have an object that simulates the radio, and a main program to actually drive the radio. This should simply be a loop that will allow the user to type in requests.

You need to give a menu that the user can choose from. It should look something like the following:

 

Press:

  P...to press the power button

  U...to press the channel Up button

  D...to press the channel Down button

  +...to press the volume Down button

  -...to press the volume Up button

  Q...to exit simulation

Also, you need to show the state of the radio after every time the user does something.

Current State:  Channel: 630 AM Volume: 11 Power: ON

 

Note: Please have an upper and lower limit on the radio station and the volume (i.e. volume should be between 0 and 100). Also, it is probably easier to use AM instead of FM, so you don't have to use decimal numbers, but either will do.

 

*********************************************************************

 

Laboratory Assignment 2:

 

Problem Statement:

 

If we go for hiking, we may need a compass to give us the directions. A Compass object will be endowed with two distinct behaviours, one called rotate, which will change the state of a Compass object by advancing the value of its state variable in the clockwise direction, and one called print, which will announce its orientation by printing a string to standard output, "NORTH" for NORTH, and so on.

 

Initially, objects of type Compass will have only one data member to record their states, and that member will be allowed to assume only four distinct values, NORTH, EAST, SOUTH and WEST. Since it can take on only an enumerated set of values you will represent it with an enum.

 

In addition, you are required to provide for initialization of Compass objects through a constructor which sets the state variable (a.k.a. data member) to the value NORTH. 


Related Questions in engineering category