This is not a test! Seriously, try and have fun with it, make it your own!
You have a toy robot on a table top, a grid of 5 x 5 units, there are no obstructions. You can issue commands to your robot allowing it to roam around the table top. But be careful, don't let it fall off!
Create an app that allows commands to be issued to the robot. The robot should be prevented from failing off the table top to its destruction.
A failed command should not stop the app, valid commands should be allowed.
The application should discard all commands until a valid place()
command has been executed.
0, 0 on the grid should be seen as bottom left.
Every command should provide visual output that the command has either succeeded or failed.
place(x, y, facing)
x
and y
are integers that relate to a location on the grid. Values that are outside the boundary of the grid should not be allowed.facing
is a string referencing the direction the robot is facing. Values NORTH
, SOUTH
, EAST
or WEST
are allowed.move()
Moves the robot 1 grid unit in the direction it is facing unless that movement will cause the robot to fall off the grid.
left()
Rotate the robot 90° anticlockwise/counterclockwise.
right()
Rotate the robot 90° clockwise.
report()
Outputs the robot's current grid location and facing direction.
place(0, 0, 'NORTH')
move()
report()
=> Output: 0, 1, NORTHplace(0, 0, NORTH)
left()
report()
=> Output: 0, 0, WESTplace(1, 2, EAST)
move()
move()
left()
move()
report()
=> Output: 3, 3, NORTH