Note: Please indent the code as per the provided screenshot of code. Otherwise, it raises indentation errors.
Program Screenshot:
Sample Output:
Code to be Copied:
#declare class Radio
class Radio():
#Declare private variables by using underscore
#before variable name
#declare station variable and set to 1
_station=1
#declare volume variable and set to 1
_volume=1
#declare turned_on variable and set to 1
_turned_on = False
#A non argument constructor
#which initialize all the values
def __init__(self):
self.__station = 1
self.__volume = 1
self.__turned_on = False
#implement method getStation()
#to return the current station value
def getStation(self):
return self.__station
#implement method getVolume()
#to return the current Volume value
def getVolume(self):
return self.__volume
#Implement the method turnOn()
#that return true when it is on
def turnOn(self):
self.__turned_on = True
#Implement the method turnOff()
#that return true when it is off
def turnOff(self):
self.__turned_on = False
#Implement the method stationUp
#to return the value current station value
def stationUp(self):
if self.__turned_on:
self.__station += 1
if self.__station > 10:
self.__station = 10
#Implement the method stationDown
#to return the value current station value
def stationDown(self):
if self.__turned_on:
self.__station -= 1
if self.__station < 1:
self.__station = 1
#Implement the method volumeUp
#to return the value current volume value
def volumeUp(self):
if self.__turned_on:
self.__volume += 1
if self.__volume > 10:
self.__volume = 10
#Implement the method volumeDown
#to return the value current volume value
def volumeDown(self):
if self.__turned_on:
self.__volume -= 1
if self.__volume < 1:
self.__volume = 1
#implement toString() method to
#print the station and volume values
def toString(self):
#if radio is turned on
if self.__turned_on:
#print the values
print('The radio station is {0} and the volume level is {1}.'
.format(self.__station, self.__volume))
#otherwise print the radio is off
else:
print('The radio is off.')
#test program
def main():
#create an object for the radio class
radio = Radio()
#print the label for turn on the radio
print('Turn radio on:')
radio.turnOn()
#call the toString() method
radio.toString()
#call volumeUp methods to increase the volume
radio.volumeUp()
radio.volumeUp()
radio.volumeUp()
#print the label
print('Turn volume up by 3:')
#call the toString() method
radio.toString()
#call stationUp methods to increase the station
radio.stationUp()
radio.stationUp()
radio.stationUp()
radio.stationUp()
radio.stationUp()
#print the label
print('Move station up by 5:')
#call the toString() method
radio.toString()
#call volumeDown methods to decrease the volume
radio.volumeDown()
#print the label
print('Turn volume down by 1:')
#call the toString() method
radio.toString()
#call stationUp methods to increase the station
radio.stationUp()
radio.stationUp()
radio.stationUp()
#print the label
print('Move station up by 3:')
#call the toString() method
radio.toString()
#call method turnOff to turn off the radio
radio.turnOff()
#print the label for turn on the radio
print('Turn radio off:')
#call the toString() method
radio.toString()
#call volumeUp methods to increase the volume
radio.volumeUp()
radio.volumeUp()
#print the label
print('Turn volume up by 2:')
#call the toString() method
radio.toString()
#call stationDown method to decrease the station
radio.stationDown()
radio.stationDown()
#print the label
print('Turn station down by 2:')
#call the toString() method
radio.toString()
#main method
main()
PYTHON Exercise #2: Design and implement class Radio to represent a radio object. The class defines...
SOLVE IN PYTHON: 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. A private variable of type int named station to represent a station number. Set to 1. A private variable of type int named volume to represent the volume setting. Set to 1. A private variable of type boolean named on to represent the radio...
** IN JAVA **: 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.A private variable of type int named station to represent a station number. Set toA private variable of type int named volume to represent the volume setting. Set to 1.A private variable of type boolean named on to represent the radio on or off. Set to false.A...
using visual studios C# implementing using system; be sure I can copy and paste. 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...
Note: According to the question, please write source
code in java only using the class method. Sample Run (output)
should be the same as displayed in the question below. Make sure
the source code is working properly and no errors.
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...
SOLVE IN PYTHON: Exercise #1: Design and implement class Circle to represent a circle object. The class defines the following attributes (variables) and methods: A private variable of type double named radius to represent the radius. Set to 1. Constructor Methods: Python : An overloaded constructor method to create a default circle. C# & Java: Default Constructor with no arguments. C# & Java: Constructor method that creates a circle with user-specified radius. Method getRadius() that returns the radius. Method setRadius()...
Design and implement class Circle to represent a circle object. The class defines the following attributes (variables) and methods: 1. A private variable of type double named radius to represent the radius. Set to 1. 2. Constructor Methods: • Python : An overloaded constructor method to create a default circle. • C# & Java: Default Constructor with no arguments. • C# & Java: Constructor method that creates a circle with user-specified radius. 3. Method getRadius() that returns the radius. 4. ...
Help please
1) Define a Java class for defining the activity of a TV set. The class contains A private int data field named channel that specifies what channel is currently set for the tuner (channels range from 1 to 120, default is 1) a. b. A private int data field named volumeLevel that specifies the volume level of the TV (range is 1 to 7; default is 1) A private boolean data field named on that determines whether the...
NEEDS TO BE IN PYTHON: (The Point class) Design a class named Point to represent a point with x- and y-coordinates. The class contains: - Two private data fields x and y that represent the coordinates with get methods. - A constructor that constructs a point with specified coordinates, with default point (0, 0). - A method named distance that returns the distance from this point to another point of the Point type. - A method named isNearBy(p1) that returns...
C# Language The ColourControl Class The class should be public. The class defines a read-only or private set public property named Value of type int. The class defines a public event named ValueChanged whose delegate type is void with two parameters, object sender and EventArgs e. The public constructor for the class is a default constructor (i.e., takes no parameters). The constructor sets the Value property to 128. The class defines a public void method named IncreaseValue. The method increases...
1. Please write the following program in Python 3. Also, please create a UML and write the test program. Please show all outputs. (The Fan class) Design a class named Fan to represent a fan. The class contains: Three constants named SLOW, MEDIUM, and FAST with the values 1, 2, and 3 to denote the fan speed. A private int data field named speed that specifies the speed of the fan. A private bool data field named on that specifies...