Skip to content

Commit 04f310f

Browse files
committed
Add documentation
1 parent 8f18c61 commit 04f310f

File tree

1 file changed

+107
-1
lines changed

1 file changed

+107
-1
lines changed

Diff for: README.md

+107-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,108 @@
1-
# toy_robot
1+
# Toy Robot
22
Toy robot simulator written in Ruby
3+
4+
## Table of Contents
5+
1. [Installation](#Installation)
6+
2. [Usage](#Usage)
7+
3. [Testing](#Testing)
8+
4. [Design](#Design)
9+
5. [Specifications](#Specifications)
10+
11+
## Installation
12+
Environment: Built on Mac OSx using Ruby -v 2.4.1
13+
14+
Make sure you have the correct version of ruby installed
15+
https://www.ruby-lang.org/en/documentation/installation/
16+
17+
Clone this Repo
18+
> $ git clone https://github.com/selenasmall/toy_robot.git
19+
20+
In root of the app run bundle install
21+
> $ gem install bundler && bundle install
22+
23+
## Usage
24+
Run the program from the app root
25+
> $ toy_robot.rb
26+
27+
Expected terminal output:
28+
> Options: PLACE X,Y,F; MOVE; LEFT; RIGHT; REPORT; EXIT
29+
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. |
39+
40+
## Testing
41+
Test by running rspec http://rspec.info/
42+
> $ bundle exec rspec
43+
44+
Expected terminal output:
45+
> ... ..Output: 0,0,NORTH
46+
> ... ... ... ...Output: 1,2,NORTH
47+
> ... ... ... ... ... ...
48+
>
49+
> Finished in 0.01938 seconds (files took 0.23698 seconds to load)
50+
> 35 examples, 0 failures
51+
52+
## Speicifications
53+
__Description:__
54+
. The application is a simulation of a toy robot moving on a square tabletop, of dimensions 5 units x 5 units.
55+
. There are no other obstruc8tions on the table surface.
56+
. The robot is free to roam around the surface of the table, but must be prevented from falling to destruc8on. Any movement
57+
that would result in the robot falling from the table must be prevented, however further valid movement commands must s8ll
58+
be allowed.
59+
60+
. Create an applica8on that can read in commands of the following form -
61+
PLACE X,Y,F
62+
MOVE
63+
LEFT
64+
RIGHT
65+
REPORT
66+
67+
. PLACE will put the toy robot on the table in posi8on X,Y and facing NORTH, SOUTH, EAST or WEST.
68+
. The origin (0,0) can be considered to be the SOUTH WEST most corner.
69+
. 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 applica8on should discard all commands in the sequence un8l a valid PLACE command has been executed.
70+
. MOVE will move the toy robot one unit forward in the direc8on it is currently facing.
71+
. LEFT and RIGHT will rotate the robot 90 degrees in the specified direc8on without changing the posi8on of the robot.
72+
. REPORT will announce the X,Y and F of the robot. This can be in any form, but standard output is sufficient.
73+
74+
. A robot that is not on the table can choose the ignore the MOVE, LEFT, RIGHT
75+
76+
and REPORT commands.
77+
. Input can be from a file, or from standard input, as the developer chooses. . Provide test data to exercise the applica8on.
78+
79+
__Constraints:__
80+
The toy robot must not fall off the table during movement. This also includes the ini8al placement of the toy robot.
81+
Any move that would cause the robot to fall must be ignored.
82+
83+
Example Input and Output:
84+
a)
85+
PLACE 0,0,NORTH
86+
MOVE
87+
REPORT
88+
Output: 0,1,NORTH
89+
90+
b)
91+
PLACE 0,0,NORTH
92+
LEFT
93+
REPORT
94+
Output: 0,0,WEST
95+
96+
c)
97+
PLACE 1,2,EAST
98+
MOVE
99+
MOVE
100+
LEFT
101+
MOVE
102+
REPORT
103+
Output: 3,3,NORTH
104+
105+
__Deliverables:__
106+
The source files, the test data and any test code.
107+
It is not required to provide any graphical output showing the movement of the toy robot.
108+

0 commit comments

Comments
 (0)