#Assignment:
Create a controller for a robot. The controller can respond to 4 commands corresponding to directions of movement (Forward, Back, Left, Right) and should maintain state of the current speed of travel.
Work in whatever language is comfortable for you. This is a test to see how you think about solving problems, not how well you know a specific technology. Show the results of your work either by writing unit tests, or making the controller interactive by accepting input and producing output to your medium of choice (console, web page, etc...).
Forward | ||
Left | 0 | Right |
Back |
##Requirements:
- Controller starts at rest, speed: 0, direction: none.
- Controller can issue four directional instructions (Forward, Back, Left, Right).
- When at rest, instructions to move in a certain direction will set direction to that direction and speed to 1.
- When moving, instructions to move in the same direction as currently moving increment speed in that direction by 1.
- When moving, instructions to move in the opposite direction as currently moving decrement speed in the current direction by 1. If the result of the decrement is that the speed is 0 the controller is now at rest, and the instructions for moving from rest apply.
- When moving, Instructions to move in a perpendicular direction to current direction will change direction to that direction and speed to 1.
- When moving, once reaching speed level four in a given direction further instructions to move in that direction return speed to 0 and directon to "none".