Page 1 of 1

USING PYTHON Please make changes/additions to the code. Note that you are only asked to provide the modified initializer

Posted: Fri Jul 08, 2022 6:38 am
by answerhappygod
USING PYTHON
Please make changes/additions to thecode. Note that you are only asked to provide the modifiedinitializer and the additional methods.
1. Change all data fields to private. Please only provide themodified initializer. (5 pts)
2. Add an instance methodnamed setStatus. setStatus method setsthe instance to status by taking informationof channel, volumneLevel,and on as arguments. Pleasemake sure that the channel and volumnLevel validity check, as inthe code below, should be maintained. (10 pts)
3. Add an instance method named getStatus, that returns all datafields as an instance's status. (5 pts)
Using Python Please Make Changes Additions To The Code Note That You Are Only Asked To Provide The Modified Initializer 1
Using Python Please Make Changes Additions To The Code Note That You Are Only Asked To Provide The Modified Initializer 1 (23.14 KiB) Viewed 63 times
class TV: definit__(self): self.channel 1 # Default channel is 1 self.volume Level = 1 # Default volume level is 1 self.on False # By default TV is off = = def turnOn(self): self.on = True def turnOff(self): self.on = False def getChannel(self): return self.channel def setChannel(self, channel): if self.on and 1 <= self.channel <= 120: self.channel = channel def getVolume Level(self): return self.volumeLevel def setVolume (self, volume Level): if self.on and \ 1 <= self.volume Level <= 7: self.volume Level volumeLevel def channelUp (self): if self.on and self.channel < 120: self.channel += 1 def channelDown (self): = if self.on and self.channel > 1: self.channel -= 1 def volumeUp (self): if self.on and self.volume Level < 7: self.volume Level += 1 def volume Down (self): if self.on and self.volume Level > 1: self.volume Level -= 1