indexing
	description: "Strategy for moving in one direction as far as possible.";
	date: "$Date: $";
	revision: "$Revision: $"

class
	STRAIGHT_LINE

inherit
  STRATEGY

creation
  make

feature

  North : INTEGER is 
  once
     Result := configuration.Northbound
  end

  South : INTEGER is
  once
     Result := configuration.Southbound
  end

  East : INTEGER is
  once
     Result := configuration.Eastbound
  end 

  West : INTEGER is
  once
     Result := configuration.Westbound
  end 

  direction : INTEGER
  
  set_direction( d : INTEGER ) is
  require
    d = North or d = South or d = West or d = East
  do
    direction := d
  ensure
    direction = d
  end 

  try_move is
  do
    if direction = North then
      mobile.try_north
    elseif direction = East then
      mobile.try_east
    elseif direction = West then 
      mobile.try_west
    elseif direction = South then 
      mobile.try_south
    end
    if not mobile.success then
      mobile.stop_moving
    end
  end

end -- class STRAIGHT_LINE
