We need the following models to solve this problem:
- Simulator, the main entrance of the application, which accepts the commands and initialise the Robot, place it on the Table, pass commands to the Robot and get the output result.
- Robot, managed by the Simulator, keep the position and direction information, but does not need to know about the details of the Table, it asks the Table for the next move, if not valid, just stands still.
- Table, holds the movement constraints, it tells the Robot if next move is valid, but does not need to know about the Robot.
Requires Ruby 2.3 for the squiggly heredoc
-
bundle install
to install minitest and simplecov gems, -
then
rake
to run the specs. -
rake run CMD_FILE=samples/a.txt
will parseCMD_FILE
and report to standard output.