-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRobot.py
More file actions
49 lines (37 loc) · 1.07 KB
/
Robot.py
File metadata and controls
49 lines (37 loc) · 1.07 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
class Robot:
__width = None
_height = None
_direction = None
def __init__(self):
self.movelength = 1
@property
def width(self):
return self.__width
@width.setter
def width(self,width):
self.__width = width
@property
def height(self):
return self._height
@height.setter
def height(self, height):
self._height = height
@property
def direction(self):
return self._direction
@direction.setter
def direction(self, direction):
self._direction = direction
def newhorizontallocation(self):
if self.direction == 2:
return self.width + self.movelength
else:
return self.width - self.movelength
def newverticallocation(self):
if self.direction == 1:
return self.height + self.movelength
else:
return self.height - self.movelength
def executeinstruction(self, command, table):
if command.validateinstruction(self, table):
command.executeinstruction(self, table)