From ad9ab2585464ab34c8abdbe797e0c73aed36c8b5 Mon Sep 17 00:00:00 2001 From: mo k Date: Sun, 12 Feb 2012 14:36:50 -0700 Subject: forward the terrain to the heading when moving forward. --- lib/rover.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/rover.rb b/lib/rover.rb index ec1356f..3e85ecf 100644 --- a/lib/rover.rb +++ b/lib/rover.rb @@ -14,7 +14,7 @@ class Rover @heading = @heading.turn_left end def move_forward(terrain) - @heading.forward(@location) + @heading.forward(@location, terrain) end end @@ -25,7 +25,7 @@ class North def turn_left West.new end - def forward(current_location) + def forward(current_location, terrain) current_location[:y] = current_location[:y]+1 end end @@ -36,7 +36,7 @@ class East def turn_left North.new end - def forward(current_location) + def forward(current_location, terrain) current_location[:x] = current_location[:x]+1 end end @@ -47,7 +47,7 @@ class West def turn_left South.new end - def forward(current_location) + def forward(current_location, terrain) current_location[:x] = current_location[:x]-1 end end @@ -58,7 +58,7 @@ class South def turn_left East.new end - def forward(current_location) + def forward(current_location, terrain) current_location[:y] = current_location[:y]-1 end end -- cgit v1.2.3