Skip to content

Makers Academy weekend challenge #1 - control the flow of planes at an airport

License

Notifications You must be signed in to change notification settings

ainsleybc/airport_challenge

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Airport Challenge

        ______
        _\____\___
=  = ==(____MA____)
          \_____\___________________,-~~~~~~~`-.._
          /     o o o o o o o o o o o o o o o o  |\_
          `~-.__       __..----..__                  )
                `---~~\___________/------------`````
                =  ===(_________)

Approach

  • Modeled an airport instructing planes to land, dependant on the weather
  • three classes: Weather, Airport & Plane
  • @landed stores the current status of the plane
  • Utilised private methods to determine if an airport is full, cleared for landing/take off or if a plane is at the airport
  • errors will be raised if any inconsistent actions are attempted (i.e taking off before landing)

Install

bundle install
irb / pry
require './lib/airport'
require './lib/plane'

Usage

example usage below:

Pry
[4] pry(main)> airport = Airport.new
=> #<Airport:0x007fad9f91fb00 @capacity=10, @planes=[], @weather=#<Weather:0x007fad9f91fa60>>
[5] pry(main)> plane = Plane.new
=> #<Plane:0x007fad9e88dcb0>
[6] pry(main)> airport.land(plane)
RuntimeError: cannot land in stormy weather
from /Users/ainsley/Projects/airport_challenge/lib/airport.rb:18:in `land'
[7] pry(main)> airport.land(plane)
=> [#<Plane:0x007fad9e88dcb0 @landed=true>]
[8] pry(main)> airport.planes
=> [#<Plane:0x007fad9e88dcb0 @landed=true>]
[9] pry(main)> airport.take_off(plane)
=> #<Plane:0x007fad9e88dcb0 @landed=false>
[10] pry(main)> airport.planes
=> []
[11] pry(main)>

Authors

Ainsley Chang

About

Makers Academy weekend challenge #1 - control the flow of planes at an airport

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 100.0%