|
| 1 | +# Toy Robot Simulator |
| 2 | + |
| 3 | +## Description |
| 4 | + |
| 5 | +- The application is a simulation of a toy robot moving on a square tabletop, |
| 6 | + of dimensions 5 units x 5 units. |
| 7 | +- There are no other obstructions on the table surface. |
| 8 | +- The robot is free to roam around the surface of the table, but must be |
| 9 | + prevented from falling to destruction. Any movement that would result in the |
| 10 | + robot falling from the table must be prevented, however further valid |
| 11 | + movement commands must still be allowed. |
| 12 | + |
| 13 | +Create an application that can read in commands of the following (textual) form: |
| 14 | + |
| 15 | + PLACE X,Y,F |
| 16 | + MOVE |
| 17 | + LEFT |
| 18 | + RIGHT |
| 19 | + REPORT |
| 20 | + |
| 21 | +- PLACE will put the toy robot on the table in position X,Y and facing NORTH, |
| 22 | + SOUTH, EAST or WEST. |
| 23 | +- The origin (0,0) can be considered to be the SOUTH WEST most corner. |
| 24 | +- The first valid command to the robot is a PLACE command, after that, any |
| 25 | + sequence of commands may be issued, in any order, including another PLACE |
| 26 | + command. The application should discard all commands in the sequence until |
| 27 | + a valid PLACE command has been executed. |
| 28 | +- MOVE will move the toy robot one unit forward in the direction it is |
| 29 | + currently facing. |
| 30 | +- LEFT and RIGHT will rotate the robot 90 degrees in the specified direction |
| 31 | + without changing the position of the robot. |
| 32 | +- REPORT will announce the X,Y and F of the robot. This can be in any form, |
| 33 | + but standard output is sufficient. |
| 34 | + |
| 35 | +- A robot that is not on the table can choose the ignore the MOVE, LEFT, RIGHT |
| 36 | + and REPORT commands. |
| 37 | +- Input can be from a file, or from standard input, as the developer chooses. |
| 38 | +- Provide test data to exercise the application. |
| 39 | +- The application must be a command line application. |
| 40 | + |
| 41 | +## Constraints |
| 42 | + |
| 43 | +- The toy robot must not fall off the table during movement. This also |
| 44 | + includes the initial placement of the toy robot. |
| 45 | +- Any move that would cause the robot to fall must be ignored. |
| 46 | + |
| 47 | +## Example Input and Output |
| 48 | + |
| 49 | +### Example a |
| 50 | + |
| 51 | + PLACE 0,0,NORTH |
| 52 | + MOVE |
| 53 | + REPORT |
| 54 | + |
| 55 | +Expected output: |
| 56 | + |
| 57 | + 0,1,NORTH |
| 58 | + |
| 59 | +### Example b |
| 60 | + |
| 61 | + PLACE 0,0,NORTH |
| 62 | + LEFT |
| 63 | + REPORT |
| 64 | + |
| 65 | +Expected output: |
| 66 | + |
| 67 | + 0,0,WEST |
| 68 | + |
| 69 | +### Example c |
| 70 | + |
| 71 | + PLACE 1,2,EAST |
| 72 | + MOVE |
| 73 | + MOVE |
| 74 | + LEFT |
| 75 | + MOVE |
| 76 | + REPORT |
| 77 | + |
| 78 | +Expected output |
| 79 | + |
| 80 | + 3,3,NORTH |
0 commit comments