Added additional comments, removed redundant initializer code.
This commit is contained in:
parent
26cc28193b
commit
730fab5287
|
@ -1,7 +1,11 @@
|
|||
class Robot:
|
||||
"""
|
||||
Class representing a single "Toy Robot". Robots instances have knowledge
|
||||
of their position, direction, and movement limits.
|
||||
of their position, direction, and movement limits (i.e. "board" size).
|
||||
|
||||
Note: Direction is specified via compass points (north, west, etc). As per
|
||||
the original problem description, the coordinates (0, 0) represent the
|
||||
SOUTHWEST corner of the board.
|
||||
|
||||
Attributes:
|
||||
DEFAULT_MAX_X (int): The default maximum allowable horizontal
|
||||
|
@ -11,6 +15,9 @@ class Robot:
|
|||
DIRECTIONS (dict): A dictionary (str: int) of direction names (e.g.
|
||||
NORTH, EAST etc) and their numerical encoding. Only the keys are
|
||||
intended for use externally as a list of valid directions.
|
||||
VALID_COMMANDS (list): A list of valid commands that can be interpreted
|
||||
by the robot. The PLACE command requires at least two additional
|
||||
parameters. See the complete problem description for more details.
|
||||
"""
|
||||
|
||||
DEFAULT_MAX_X = 5
|
||||
|
@ -328,5 +335,5 @@ class Robot:
|
|||
return "{},{},{}".format(
|
||||
self._position_x,
|
||||
self._position_y,
|
||||
{v: k for k, v in Robot.DIRECTIONS.items()}[self._direction],
|
||||
self.get_direction()
|
||||
)
|
||||
|
|
|
@ -11,19 +11,19 @@ def feed_file(filename: str, robot: toyrobot.Robot):
|
|||
|
||||
def main():
|
||||
print('a)')
|
||||
feed_file('example_a.txt', toyrobot.Robot(6, 6))
|
||||
feed_file('example_a.txt', toyrobot.Robot())
|
||||
print()
|
||||
|
||||
print('b)')
|
||||
feed_file('example_b.txt', toyrobot.Robot(6, 6))
|
||||
feed_file('example_b.txt', toyrobot.Robot())
|
||||
print()
|
||||
|
||||
print('c)')
|
||||
feed_file('example_c.txt', toyrobot.Robot(6, 6))
|
||||
feed_file('example_c.txt', toyrobot.Robot())
|
||||
print()
|
||||
|
||||
print('d)')
|
||||
feed_file('example_d.txt', toyrobot.Robot(6, 6))
|
||||
feed_file('example_d.txt', toyrobot.Robot())
|
||||
print()
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
Loading…
Reference in New Issue