Commit 85e494c
Changed files (2)
lib
lib/location.rb
@@ -0,0 +1,16 @@
+class Location
+ attr_reader :location, :heading
+ def initialize(x, y, heading)
+ @location = {:x => x, :y => y}
+ @heading = heading
+ end
+ def rotate(degrees)
+ @heading = @heading.rotate(degrees)
+ end
+ def is_facing(direction)
+ @heading.represents? direction
+ end
+ def to_s
+ "#{@location[:x]} #{@location[:y]} #{@heading}"
+ end
+end
lib/rover.rb
@@ -1,3 +1,4 @@
+require 'location'
class Rover
def initialize(heading, x, y, plateau)
@plateau = plateau
@@ -24,20 +25,3 @@ class Rover
@location.to_s
end
end
-
-class Location
- attr_reader :location, :heading
- def initialize(x, y, heading)
- @location = {:x => x, :y => y}
- @heading = heading
- end
- def rotate(degrees)
- @heading = @heading.rotate(degrees)
- end
- def is_facing(direction)
- @heading.represents? direction
- end
- def to_s
- "#{@location[:x]} #{@location[:y]} #{@heading}"
- end
-end