/* * @topic T02389 Assignment a8 -- Airline Flight Schedule demo Dec 9 2014 * @brief class Flight */ package a8demo; public class Flight implements Comparable<Flight> { // data attributes //Airline Code -- the code of an existing airline. Airline airline; //Flight number (ID) -- make sure no duplicate //flight numbers per airline are permitted in the system. String flightID; // "DL1011" type of string //Flight status -- S/C/D/A for Scheduled/Cancelled/Departed/Arrived String flightStatus; //Flight Type -- D/I for Domestic/International String flightType; DepartureArrivalInfo departure; DepartureArrivalInfo arrival; // constructors public Flight( Airline airline, String flightID, String flightStatus, String flightType, DepartureArrivalInfo departure, DepartureArrivalInfo arrival ) { this.airline = airline; this.flightID = flightID; this.flightStatus = flightStatus; this.flightType = flightType; this.departure = departure; this.arrival = arrival; } //-------------------------------------------- // operations //-------------------------------------------- @Override public int compareTo( Flight other ) { DepartureArrivalInfo infoThis = arrival; DepartureArrivalInfo infoOther = other.arrival; // return // -1 if this < other // 0 if this == other // +1 of this > other if ( infoThis.getTime() < infoOther.getTime() ) { return -1; } else if ( infoThis.getTime() == infoOther.getTime() ) { return 0; } else { return +1; } } public DepartureArrivalInfo getDeparture() { return departure; } public DepartureArrivalInfo getArrival() { return arrival; } public Airline getAirline() { return airline; } public void setAirline(Airline airline) { this.airline = airline; } public String getFlightID() { return flightID; } public void setFlightID(String flightID) { this.flightID = flightID; } public String getFlightStatus() { return flightStatus; } public void setFlightStatus(String flightStatus) { this.flightStatus = flightStatus; } public String getFlightType() { return flightType; } public void setFlightType(String flightType) { this.flightType = flightType; } public String toString() { return flightID; } }//class Flight