Question: Exercise #2: Design and implement class Radio to represent a radio object. The class defines the following attributes (variables) and methods Assume that the station

 Exercise #2: Design and implement class Radio to represent a radio

Exercise #2: Design and implement class Radio to represent a radio object. The class defines the following attributes (variables) and methods Assume that the station and volume settings range from 1 to 10 1. A private variable of type int named station to represent a station number. Set to 1. 2. A private variable of type int named volume to represent the volume setting. Set to 1 3. A private variable of type boolean named on to represent the radio on or off. Set to false Page 1 of2 4. A non-argument constructor method to create a default radio 5. Method getStation ) that returns the station 6. Method getVolume () that returns the volume 7. Method turnOn () that turns the radio on 8. Method turnOff) that turns the radio off 9. Method stationUp ) that increments the station by 1 only when the radio is on 10. Method stationDown () that decrements the station by 1 only when the radio is on 11. Method volumeUp ) that increment the volume by 1 only when the radio is on 12. Method volumeDown () that decrements the volume by 1 only when the radio is on 13. Method toString ) to printout a of the radio as folloWs (if the radio is on) The radio station isX and the volume level is Y Where X and Y are the values of variables station and volume If the radio is off, the message is: The radio is off Now design and implement a test program to create a default radio object and test all class methods on the object in random order. Print the object after each method call and use meaningful label for each method call as shown in the following sample run Sample run Turn radio on: The radio station is 1 and the volume level is 1 Turn volume up by 3: The radio station is 1 and the volume level is 4. Move station up by 5: The radio station is 6 and the volume level is 4

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!