diff options
| author | mo k <mo@mokhan.ca> | 2012-02-14 13:00:40 -0700 |
|---|---|---|
| committer | mo k <mo@mokhan.ca> | 2012-02-14 13:00:40 -0700 |
| commit | 3cded90bf0ec8812f62ebb2041be5cfbc1005a1a (patch) | |
| tree | 659a76e4d5d50950e2cc62de83438707dbf815a9 /lib | |
| parent | ee6968d6fde0072e4bdb1e7b1b047189a6c7157e (diff) | |
remove terrain parameter when moving a heading forward.
Diffstat (limited to 'lib')
| -rwxr-xr-x | lib/east.rb | 6 | ||||
| -rwxr-xr-x[-rw-r--r--] | lib/north.rb | 6 | ||||
| -rwxr-xr-x | lib/rover.rb | 3 | ||||
| -rwxr-xr-x | lib/south.rb | 6 | ||||
| -rwxr-xr-x[-rw-r--r--] | lib/west.rb | 2 |
5 files changed, 8 insertions, 15 deletions
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 index 9fe6aa8..769eb66 100644..100755 --- 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 index b77dd3f..58cdac2 100644..100755 --- 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 |
