forked from zhuwenzhang/Python-base
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTV.py
More file actions
41 lines (31 loc) · 1021 Bytes
/
TV.py
File metadata and controls
41 lines (31 loc) · 1021 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
class TV:
def __init__(self):
self.channel = 1
self.volumeLevel = 1
self.on = False
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(self):
return self.volumeLevel
def setVolume(self, volumeLevel):
if self.on and 1 <= self.volumeLevel <= 7:
self.volumeLevel = 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.volumeLevel < 7:
self.volumeLevel += 1
def volumeDown(self):
if self.on and self.volumeLevel > 1:
self.volumeLevel -= 1