From a1a0e9e7d63aa013fdfc54e87ce05ba776cd4135 Mon Sep 17 00:00:00 2001 From: mo k Date: Sun, 12 Feb 2012 14:15:01 -0700 Subject: instead of returning a new coordinates hash just update the hash. --- lib/rover.rb | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/rover.rb b/lib/rover.rb index 82ca1c3..35ab1f9 100644 --- a/lib/rover.rb +++ b/lib/rover.rb @@ -14,8 +14,7 @@ class Rover @heading = @heading.turn_left end def move_forward(terrain) - @location = @heading.next(@location) - #@location = {:x => 0,:y => 1} + @heading.forward(@location) end end @@ -29,8 +28,8 @@ class North def turn_left West.new end - def next(current_location) - {:x => current_location[:x], :y => current_location[:y]+1 } + def forward(current_location) + current_location[:y] = current_location[:y]+1 end end class East @@ -65,8 +64,8 @@ class South def turn_left East.new end - def next(current_location) - {:x => current_location[:x], :y => current_location[:y]-1 } + def forward(current_location) + current_location[:y] = current_location[:y]-1 end end -- cgit v1.2.3