Navigation Menu

Skip to content


Validate the position of the placed robot against the table coordinates
Browse files Browse the repository at this point in the history
  • Loading branch information
SelenaSmall committed Aug 26, 2017
1 parent 0f842b7 commit b39456f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions toy_robot.rb
@@ -1,7 +1,9 @@

require_relative './lib/table'
require_relative './lib/robot'

table =
robot =

# Keep reading user inputs while the program is running
Expand All @@ -11,9 +13,10 @@

unless input == 'EXIT'
position =
puts "Position: #{position.x},#{position.y}"
# Only update robot if the position is valid on the table
robot.update_robot(position) if table.valid_position?(position.x, position.y)

puts "Position: #{position.x},#{position.y}"

puts 'placed' unless robot.not_in_place?
Expand Down

0 comments on commit b39456f

Please sign in to comment.