class DallasMarsRover::Zone
This class defines the survey zone for the rover
Attributes
zone_size_x[R]
zone_size_y[R]
Public Class Methods
new(commander)
click to toggle source
Load the zone boundaries @param [Commander] commander @return [Zone] zone object
# File lib/mars_rover/zone.rb, line 7 def initialize(commander) @zone_size_x = commander.zone_size[:x].to_i @zone_size_y = commander.zone_size[:y].to_i end
Public Instance Methods
valid_position?(pos_x, pos_y)
click to toggle source
@param [Integer] pos_x is the new x co-ord @param [Integer] pos_y is the new y co-ord @return [Boolean] is the new position valid
# File lib/mars_rover/zone.rb, line 15 def valid_position?(pos_x, pos_y) pos_x >= 1 && pos_x < zone_size_x && pos_y >= 1 && pos_y < zone_size_y end