We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0f842b7 commit b39456fCopy full SHA for b39456f
toy_robot.rb
@@ -1,7 +1,9 @@
1
#!/usr/bin/ruby
2
3
+require_relative './lib/table'
4
require_relative './lib/robot'
5
6
+table = Table.new
7
robot = Robot.new
8
9
# Keep reading user inputs while the program is running
@@ -11,9 +13,10 @@
11
13
12
14
unless input == 'EXIT'
15
position = robot.place(input)
- puts "Position: #{position.x},#{position.y}"
16
+ # Only update robot if the position is valid on the table
17
+ robot.update_robot(position) if table.valid_position?(position.x, position.y)
18
- robot.update_robot(position)
19
+ puts "Position: #{position.x},#{position.y}"
20
21
puts 'placed' unless robot.not_in_place?
22
next
0 commit comments