From 3cded90bf0ec8812f62ebb2041be5cfbc1005a1a Mon Sep 17 00:00:00 2001 From: mo k Date: Tue, 14 Feb 2012 13:00:40 -0700 Subject: remove terrain parameter when moving a heading forward. --- lib/east.rb | 6 ++---- lib/north.rb | 6 ++---- lib/rover.rb | 3 +-- lib/south.rb | 6 ++---- lib/west.rb | 2 +- 5 files changed, 8 insertions(+), 15 deletions(-) mode change 100644 => 100755 lib/north.rb mode change 100644 => 100755 lib/west.rb (limited to 'lib') diff --git a/lib/east.rb b/lib/east.rb index fd5752d..40745a4 100755 --- a/lib/east.rb +++ b/lib/east.rb @@ -5,9 +5,7 @@ class East def turn_left North.new end - def forward(location, terrain) - unless terrain.is_out_of_bounds( {:x => location[:x]+1, :y => location[:y]}) - location[:x] = location[:x]+1 - end + def forward(location) + location[:x] = location[:x]+1 end end diff --git a/lib/north.rb b/lib/north.rb old mode 100644 new mode 100755 index 9fe6aa8..769eb66 --- a/lib/north.rb +++ b/lib/north.rb @@ -5,9 +5,7 @@ class North def turn_left West.new end - def forward(location, terrain) - unless terrain.is_out_of_bounds({:x =>location[:x],:y => location[:y]+1}) - location[:y] = location[:y]+1 - end + def forward(location) + location[:y] = location[:y]+1 end end diff --git a/lib/rover.rb b/lib/rover.rb index fa5d976..779b6f9 100755 --- a/lib/rover.rb +++ b/lib/rover.rb @@ -14,8 +14,7 @@ class Rover @heading = @heading.turn_left end def move_forward(terrain) -# terrain.move_forward(@heading, @location) - @heading.forward(@location, terrain) + terrain.move_forward(@heading, @location) end end diff --git a/lib/south.rb b/lib/south.rb index 5e8a434..5c7576a 100755 --- a/lib/south.rb +++ b/lib/south.rb @@ -5,9 +5,7 @@ class South def turn_left East.new end - def forward(location, terrain) - unless terrain.is_out_of_bounds({:x => location[:x], :y => location[:y]-1}) - location[:y] = location[:y]-1 - end + def forward(location) + location[:y] = location[:y]-1 end end diff --git a/lib/west.rb b/lib/west.rb old mode 100644 new mode 100755 index b77dd3f..58cdac2 --- a/lib/west.rb +++ b/lib/west.rb @@ -5,7 +5,7 @@ class West def turn_left South.new end - def forward(current_location, terrain) + def forward(current_location) current_location[:x] = current_location[:x]-1 end end -- cgit v1.2.3