Permalink
Browse files

Update robot position when user inputs move command

  • Loading branch information...
SelenaSmall committed Aug 26, 2017
1 parent de39a04 commit fa0d47d0cd1d486dbf5aa0d02e577fdca5088e6b
Showing with 16 additions and 1 deletion.
  1. +16 −1 lib/handle_input.rb
@@ -58,7 +58,22 @@ def interpret(command)
puts "New position #{robot.position.x},#{robot.position.y},#{robot.position.f}"
end
puts 'moving' if move.match?(command)
# MOVE
if move.match?(command)
case robot.position.f
when 'NORTH'
robot.position.y += 1
when 'EAST'
robot.position.x += 1
when 'SOUTH'
robot.position.y -= 1
when 'WEST'
robot.position.x -= 1
end
robot.update_robot(robot.position)
puts "New position #{robot.position.x},#{robot.position.y},#{robot.position.f}"
end
puts 'reporting' if report.match?(command)
end

0 comments on commit fa0d47d

Please sign in to comment.