Class Airline

  • All Implemented Interfaces:
    Retailer

    public class Airline
    extends Object
    implements Retailer
    Class representing an airline in the flight examples.
    Author:
    Herbert Praehofer
    • Field Detail

      • AIRLINES

        public static final Airline[] AIRLINES
        Array with some airline objects.
      • DELAY_CONST

        private static final int DELAY_CONST
        Constant for the delay of retrieving a flight from an airline.
        See Also:
        Constant Field Values
      • DELAY_VARIATION

        private static final int DELAY_VARIATION
        Constant for the variation of the delay of retrieving a flight from an airline.
        See Also:
        Constant Field Values
      • RAND

        static final Random RAND
        A random number generator
      • code

        public final String code
        The code of the airline
      • name

        public final String name
        The name of the airline
    • Constructor Detail

      • Airline

        public Airline​(String code,
                       String name)
        Constructor setting code and name of the airline.
        Parameters:
        code - the code of the airline
        name - the name of the airline
    • Method Detail

      • findFlight

        public Flight findFlight​(String from,
                                 String to,
                                 LocalDate date)
        Returns a flight provided by the airline.
        Parameters:
        from - the origin
        to - the destination
        date - the date
        Returns:
        the flight object provided by the airline
      • findFlightAsync

        public CompletableFuture<Flight> findFlightAsync​(String from,
                                                         String to,
                                                         LocalDate date)
        Returns a completable future for a flight provided by the airline.
        Parameters:
        from - the origin
        to - the destination
        date - the date
        Returns:
        a completable future for flight object provided by the airline
      • findFlights

        public List<Flight> findFlights​(String from,
                                        String to,
                                        LocalDate date)
        Returns a list of flights offered by the airline.
        Parameters:
        from - the origin
        to - the destination
        date - the date
        Returns:
        the list of flights offered by the airline
      • getOffer

        public Offer getOffer​(Flight flight)
        Returns a offer for a flight.
        Specified by:
        getOffer in interface Retailer
        Parameters:
        flight - the flight
        Returns:
        the offer for the flight
      • toString

        public String toString()
        Returns a string representation of the airline.
        Overrides:
        toString in class Object
        Returns:
        the string representation