-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.rb
45 lines (31 loc) · 953 Bytes
/
main.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
require_relative 'lib/commands_parser'
require_relative './robot'
class Main
def self.start_robot
inst = <<-instructions
\n\n\n
ENTER COMMANDS TO MOVE THE ROBOT WITHIN THE TABLE (5x5)\n\n
VALID COMMANDS LISTED BELOW\n\n
PLACE X,Y,DIRECTION (X,Y range from 0-4)\n
MOVE -> MOVES THE ROBOT 1 UNIT IN THE DIRECTION IT IS FACING\n
LEFT -> ROTATE THE ROBOT 90 DEGREES LEFT\n
RIGHT -> ROTATE THE ROBOT 90 DEGREES RIGHT\n
REPORT -> DISPLAY X,Y,DIRECTION OF ROBOT\n\n
TYPE EXIT TO STOP
instructions
puts inst;puts
robot = Robot.new
puts;puts
loop do
user_input = gets.chomp.downcase
if user_input == 'help'
puts;puts;puts inst;puts;puts
end
break if user_input == "exit"
resp = robot.process_commands(user_input)
puts "!!!! INVALID COMMAND, TYPE `help` TO SEE A LIST OF VALID COMMANDS !!!!" unless resp
puts resp if resp.class == String
end
end
end
Main.start_robot