-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclass_robot
More file actions
34 lines (22 loc) · 750 Bytes
/
class_robot
File metadata and controls
34 lines (22 loc) · 750 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
'''
'''
class Robot:
def __init__(self, name, build_year): #The constructor for the object
self.name = name
self.build_year = build_year
def SayHello(self):
print("Hello, I am " + self.name)
def SetName(self, name):
self.name = name
def GetName(self):
return self.name
def SetBuildYear(self, build_year):
self.build_year = build_year
def GetBuildYear(self):
return str(self.build_year)
if __name__ == "__main__":
x = Robot("John", 2015)
y = Robot("Marvin", 2018)
for robots in [x,y]:
robots.SayHello()
print("I was built in the year " + robots.GetBuildYear() + "!")