diff options
| author | mo k <mo@mokhan.ca> | 2012-02-12 14:15:01 -0700 |
|---|---|---|
| committer | mo k <mo@mokhan.ca> | 2012-02-12 14:15:01 -0700 |
| commit | a1a0e9e7d63aa013fdfc54e87ce05ba776cd4135 (patch) | |
| tree | a23ea2f40d4338f61816852c9571a75df6ef6ef8 | |
| parent | c15210d88f585c4249705043f590089d4b4dcd5b (diff) | |
instead of returning a new coordinates hash just update the hash.
| -rw-r--r-- | lib/rover.rb | 11 |
1 files 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 |
