Class Flight

java.lang.Object
  extended by Flight
All Implemented Interfaces:
Comparable<Flight>

public class Flight
extends Object
implements Comparable<Flight>

Information about one flight on the airline. A flight has a number, arrival and departure Airports, arrival and departure times, and a duration. Flights can be compared based on departure time.

Arrival and departure times are encoded as four digit integers where the first two digits represent hours and the last two represent minutes. For example, 100 is 1:00AM, 1300 is 1:00PM, 17:58 is 5:58PM. If a flight lands after midnight, the hours may be larger than 24.

The duration of a flight is minutes. Note that because of time zone changes, adding the duration to the departure time will not always give you the arrival time. For example, if a flight leaves LA and 8:00AM and takes 6 hours to fly to NY, the duration is 360 minutes, but the arrival time is 5:00PM.


Field Summary
protected  Airport arrives
          arrival airport
protected  int arriveTime
          arrival time (in 24 hour time as 4 digits, ie 1530 for 130pm)
protected  Airport departs
          departure airport
protected  int departTime
          departure time (in 24 hour time as 4 digits, ie 1530 for 330pm)
protected  int duration
          duration of the flight (in minutes)
protected  int number
          flight number
 
Constructor Summary
Flight(int number, Airport departs, Airport arrives, int departTime, int arriveTime, int duration)
           
 
Method Summary
 Airport arrives()
           
 int arriveTime()
           
 int compareTo(Flight o)
           
 Airport departs()
           
 int departTime()
           
 int duration()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

number

protected int number
flight number


departs

protected Airport departs
departure airport


arrives

protected Airport arrives
arrival airport


departTime

protected int departTime
departure time (in 24 hour time as 4 digits, ie 1530 for 330pm)


arriveTime

protected int arriveTime
arrival time (in 24 hour time as 4 digits, ie 1530 for 130pm)


duration

protected int duration
duration of the flight (in minutes)

Constructor Detail

Flight

public Flight(int number,
              Airport departs,
              Airport arrives,
              int departTime,
              int arriveTime,
              int duration)
Method Detail

departTime

public int departTime()

arriveTime

public int arriveTime()

departs

public Airport departs()

arrives

public Airport arrives()

duration

public int duration()

compareTo

public int compareTo(Flight o)
Specified by:
compareTo in interface Comparable<Flight>

toString

public String toString()
Overrides:
toString in class Object