You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> Options: PLACE X,Y,F; MOVE; LEFT; RIGHT; REPORT; EXIT
29
26
30
-
Available commands
31
-
| Command | Description |
32
-
| ------------- | ------------- |
33
-
| PLACE X,Y,F | Place the robot on the table at coordinates x,y and facing the direction f. Valid x andy values are between 0-4. Valid directions are WEST, NORTH, EAST, SOUTH. Example Input: "PLACE 0,0,NORTH"|
34
-
| MOVE | Move the robot forward 1 step in the direction it is facing. |
35
-
| LEFT | Turn the robot's direction 90 degress to the left. I.e. if the robot is facing NORTH, 1 left turn will turn the robot's direction to WEST. |
36
-
| RIGHT | Turn the robot's direction 90 degress to the right. I.e. if the robot is facing NORTH, 1 left turn will turn the robot's direction to EAST. |
37
-
| REPORT | Output the current position of the robot. Example Output: "Output: 0,0,NORTH" |
38
-
| EXIT | Gracefully exit the program. |
27
+
Commands | Description
28
+
--- | ---
29
+
PLACE X,Y,F | Place the robot on the table at coordinates x,y and facing the direction f. Valid x andy values are between 0-4. Valid directions are WEST, NORTH, EAST, SOUTH. Example Input: "PLACE 0,0,NORTH"
30
+
MOVE | Move the robot forward 1 step in the direction it is facing.
31
+
LEFT | Turn the robot's direction 90 degress to the left. I.e. if the robot is facing NORTH, 1 left turn will turn the robot's direction to WEST.
32
+
RIGHT | Turn the robot's direction 90 degress to the right. I.e. if the robot is facing NORTH, 1 left turn will turn the robot's direction to EAST.
33
+
REPORT | Output the current position of the robot. Example Output: "Output: 0,0,NORTH"
34
+
EXIT | Gracefully exit the program.
35
+
36
+
***
39
37
40
38
## Testing
41
39
Test by running rspec http://rspec.info/
42
40
> $ bundle exec rspec
43
41
44
42
Expected terminal output:
45
-
> ... ..Output: 0,0,NORTH
46
-
>
47
-
> ... ... ... ...Output: 1,2,NORTH
43
+
> ... ... ... ... ... .Output: 1,2,NORTH
48
44
>
49
-
> ... ... ... ... ... ...
45
+
> ... ... ... ... ... ... .
50
46
>
51
47
> Finished in 0.01938 seconds (files took 0.23698 seconds to load)
52
48
>
53
49
> 35 examples, 0 failures
54
50
55
-
## Speicifications
56
-
__Description:__
51
+
***
52
+
53
+
## Specifications
54
+
### Description
57
55
58
56
The application is a simulation of a toy robot moving on a square tabletop, of dimensions 5 units x 5 units.
59
57
60
58
There are no other obstructions on the table surface.
61
59
62
60
The robot is free to roam around the surface of the table, but must be prevented from falling to destruction. Any movement that would result in the robot falling from the table must be prevented, however further valid movement commands must still be allowed.
63
61
64
-
Create an application that can read in commands of the following form -
62
+
Create an application that can read in commands of the following form - PLACE X,Y,F | MOVE | LEFT | RIGHT | REPORT
65
63
66
-
* PLACE X,Y,F
64
+
__PLACE__
67
65
68
-
*MOVE
66
+
*Will put the toy robot on the table in position X,Y and facing NORTH, SOUTH, EAST or WEST.
69
67
70
-
*LEFT
68
+
*The origin (0,0) can be considered to be the SOUTH WEST most corner.
71
69
72
-
*RIGHT
70
+
*The first valid command to the robot is a PLACE command, aXer that, any sequence of commands may be issued, in any order, including another PLACE command. The application should discard all commands in the sequence until a valid PLACE command has been executed.
73
71
74
-
* REPORT
75
-
76
-
PLACE will put the toy robot on the table in position X,Y and facing NORTH, SOUTH, EAST or WEST.
72
+
__MOVE__
77
73
78
-
The origin (0,0) can be considered to be the SOUTH WEST most corner.
74
+
* Will move the toy robot one unit forward in the direction it is currently facing.
79
75
80
-
The first valid command to the robot is a PLACE command, aXer that, any sequence of commands may be issued, in any order, including another PLACE command. The application should discard all commands in the sequence until a valid PLACE command has been executed.
76
+
__LEFT and RIGHT__
81
77
82
-
MOVE will move the toy robot one unit forward in the direction it is currently facing.
78
+
* Will rotate the robot 90 degrees in the specified direction without changing the position of the robot.
83
79
84
-
LEFT and RIGHT will rotate the robot 90 degrees in the specified direction without changing the position of the robot.
80
+
__REPORT__
85
81
86
-
REPORT will announce the X,Y and F of the robot. This can be in any form, but standard output is sufficient.
82
+
* Will announce the X,Y and F of the robot. This can be in any form, but standard output is sufficient.
87
83
88
-
A robot that is not on the table can choose the ignore the MOVE, LEFT, RIGHT
89
-
90
-
and REPORT commands.
84
+
* A robot that is not on the table can choose the ignore the MOVE, LEFT, RIGHT and REPORT commands.
91
85
92
-
Input can be from a file, or from standard input, as the developer chooses. . Provide test data to exercise the application.
86
+
*Input can be from a file, or from standard input, as the developer chooses. . Provide test data to exercise the application.
93
87
94
-
__Constraints:__
88
+
### Constraints
95
89
96
90
The toy robot must not fall off the table during movement. This also includes the initial placement of the toy robot.
97
91
Any move that would cause the robot to fall must be ignored.
@@ -130,8 +124,7 @@ c)
130
124
>
131
125
> Output: 3,3,NORTH
132
126
133
-
__Deliverables:__
127
+
### Deliverables
134
128
135
129
The source files, the test data and any test code.
136
130
It is not required to provide any graphical output showing the movement of the toy robot.
0 commit comments