Skip to content

Commit

Permalink
Finish implementing move_backward
Browse files Browse the repository at this point in the history
  • Loading branch information
ColumODonovann committed Nov 9, 2023
1 parent 168ed07 commit 8518c53
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/mars_rover.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,15 @@ def move_forward
end

def move_backward
if point.direction == 'N'
@point = @point.new_move_y(-1)
elsif point.direction == 'S'
case point.direction
when 'E'
@point = @point.new_move_x(-1)
when 'S'
@point = @point.new_move_y(1)
when 'W'
@point = @point.new_move_x(1)
when 'N'
@point = @point.new_move_y(-1)
end
end
end

0 comments on commit 8518c53

Please sign in to comment.