class Airplane
attr_reader :weight, :aircraft_type
attr_accessor :speed, :altitude, :course
def initialize(aircraft_type, options = {})
@aircraft_type = aircraft_type.to_s
@course = options[:course.to_s + "%"] || rand(1...360).to_s + "%"
end
How I can use minimum and maximum allowable values for the hash in initialize from 1 to 360?
Example:
airplane1 = Airplane.new("Boeing 74", course: 200)
p radar1.airplanes
=> [#<Airplane:0x000000023dfc78 @aircraft_type="Boeing 74", @course="200%"]
But if I set to course value 370, airplane1 should not work
This could be refactored i’m sure but this is what i came up with