Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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 2 of 2 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 meaningful description of the radio as follows(if the radio is on): The radio station is X 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. Turn volume down by 1: The radio station is 6 and the volume level is 3. Move station up by 3: The radio station is 9 and the volume level is 3. Turn radio off. The radio is off. Turn volume up by 2: The radio is off. Turn station down by 2: The radio is off.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Semantics In Databases Second International Workshop Dagstuhl Castle Germany January 2001 Revised Papers Lncs 2582

Authors: Leopoldo Bertossi ,Gyula O.H. Katona ,Klaus-Dieter Schewe ,Bernhard Thalheim

2003rd Edition

3540009574, 978-3540009573

More Books

Students also viewed these Databases questions

Question

3. How frequently do the assessments occur?

Answered: 1 week ago