/airport_challenge

Fly!

Primary LanguageRubyOtherNOASSERTION

Aeroplane challenge

Summary

This package allows air traffic controllers (ATCs) to track and control the movements of planes between airports.

Aeroplanes and airports are each represented by dedicated classes. Aeroplanes track their location and support taking-off and landing. Airports act as containers for aeroplanes and also provide traffic control functions, via the ATC class.

ATCs can order planes to take off or land at any known airport. The ATC class will automatically check for any safety concerns of logistical errors. It will prevent any movement that isn't safe or possible.

Safety features:

  • Doesn't permit taking-off or landing in poor weather
  • Doesn't permit aircraft to land at airports without spare capacity.

Developer features:

  • Allows specification of capacity and weather patterns for each Airport
  • Aeroplanes recognise orders that don't make sense, e.g. land when landed

Possible extensions:

  • Use ATC class to track all known airports and aircraft
  • Use ATC class to dispatch aircraft directly, by name or ID

Classes

Note that the term dock means to land regardless of weather conditions ie. to be delivered on the ground.

Aeroplane

Represents any aircraft. Can optionally initialize with a name and an airport. Will attempt to dock if initialized with an airport and raises an error if this isn't possible (to prevent capacity overflow).

Supports land and take-off operations. Aeroplanes know if they are flying or not.

Contains a reference to its current airport, if it has one.

Airport

Represents any airport. Can optionally initialize with a name, weather generator and capacity limit. Weather generator defaults to a new default Weather instance (see Weather) and capacity defaults to 50.

The airport knows if the weather is safe and whether it is at capacity or not.

Provides a range of functions to handle incoming and outgoing aircraft, including safety checks. However, these are usually called from the Aeroplane (see Aeroplane).

Uses the ATC singleton class to carry out safety checks.

Weather

Represents the weather at an airport. Currently only capable of generating two weather patterns (clear and stormy). Can optionally initialize with a storm probability (from 0-1), which defaults to 5% (0.05).

Use get method to generate weather.

ATC

This class is a singleton that it not intended to be initialized. The clear method is used to generate an Operation.

Used only with the following syntax:

ATC.clear(airport).to(:land)

Operation

Generated by the clear method of the ATC class. Supports only one method.

Use the to method to provide a symbol representing the operation that is supposed to be cleared at that airport.

See ATC for the proper syntax and usage of this class.