-
Notifications
You must be signed in to change notification settings - Fork 0
/
oop.py
57 lines (42 loc) · 1.17 KB
/
oop.py
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
49
50
51
52
53
54
55
56
57
class Tools:
def __init__(self, tool):
"""Initialise les outils."""
self.tools = [tool]
def addTools(self, tool):
self.tools.append(tool)
print(tool + ' Added !')
def removeTools(self, tools):
index = self.tools.index(tool)
del self.tools[index]
class Marteau:
def __init__(self, color):
self.color = color
def paint(self, color):
print('Paint in ' + color)
def hammer_in(nail):
nail.hammer_in()
def remove(nail):
nail.remove()
color = 'red', 'blue', 'yellow'
class Tournevis:
def __init__(self, color):
print('The screw is ' + color)
def tighten(screw):
screw.tighten()
def loosen(screw):
screw.loosen()
size = 2
tool = Marteau('green')
new = Marteau('lol')
screw = Tournevis('Brown')
toolBox = Tools('marteau')
print(new.paint('yellow'))
print(tool.color)
tool.color = "No color"
print(toolBox.addTools('visseuse'))
print(toolBox.addTools('perceuse'))
print(toolBox.addTools('laser'))
print(toolBox.addTools('brioche'))
print(tool.color)
print(toolBox.tools)
# print(toolBox.addTools('yes'))