-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTV.py
More file actions
48 lines (34 loc) · 1.16 KB
/
TV.py
File metadata and controls
48 lines (34 loc) · 1.16 KB
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
42
43
44
45
46
47
48
# Pseudocode
# 1. Create a class and define functions and methods for operating the TV
class TV:
def __init__(self):
self.channel = 1
self.volume_level = 1
self.on = False
def turn_on(self):
self.on = True
def turn_off(self):
self.on = False
def get_channel(self):
return self.channel
def set_channel(self, channel):
if 1 <= channel <= 120:
self.channel = channel
def get_volume(self):
return self.volume_level
def set_volume(self, volume_level):
if 1 <= volume_level <= 7:
self.volume_level = volume_level
def channel_up(self):
if self.channel < 120:
self.channel += 1
def channel_down(self):
if self.channel > 1:
self.channel -= 1
def volume_up(self):
if self.volume_level < 7:
self.volume_level += 1
def volume_down(self):
if self.volume_level > 1:
self.volume_level -= 1
# 2. When the class or the blueprint of the TV is done, create another file named test_tv.py to test and produce the channel and volume level of tv 1 and tv 2