Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Update robot position when user inputs move command
  • Loading branch information
SelenaSmall committed Aug 26, 2017
1 parent de39a04 commit fa0d47d
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion lib/handle_input.rb
Expand Up @@ -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
Expand Down

0 comments on commit fa0d47d

Please sign in to comment.