Class Company


  • public class Company
    extends java.lang.Object
    Represent a flight company
    • Constructor Summary

      Constructors 
      Constructor Description
      Company​(java.lang.String prefix, java.lang.String name)
      Constructor
    • Constructor Detail

      • Company

        public Company​(java.lang.String prefix,
                       java.lang.String name)
        Constructor
        Parameters:
        prefix - the company prefix
        name - the company name
        Throws:
        java.lang.IllegalArgumentException - on null or empty parameter
    • Method Detail

      • getName

        public java.lang.String getName()
        Getter
        Returns:
        the company name
      • setName

        public void setName​(java.lang.String name)
        Setter
        Parameters:
        name - the company name
        Throws:
        java.lang.IllegalArgumentException - on null or empty parameter
      • getFlights

        public java.util.ArrayList<FlightId> getFlights()
        Getter
        Returns:
        the company flight ids
      • getFlight

        public Flight getFlight​(FlightId id)
        Getter
        Parameters:
        id - the flight id
        Returns:
        the flight associated
        Throws:
        java.lang.IllegalArgumentException - on null parameter
      • addFlight

        public void addFlight​(java.time.ZonedDateTime departure,
                              TripBuilder trip)
        Create and add a flight
        Parameters:
        trip - the flight trip as a tripbuilder
        departure - the flight departure date
        Throws:
        java.lang.IllegalArgumentException - on null parameter
      • addFlight

        public void addFlight​(java.time.ZonedDateTime departure,
                              Trip trip)
        Create and add a flight
        Parameters:
        trip - the flight trip
        departure - the flight departure date
        Throws:
        java.lang.IllegalArgumentException - on null parameter
      • addRegularFlight

        public void addRegularFlight​(java.time.ZonedDateTime departure,
                                     int i)
        Create and add a regular flight from the registry
        Parameters:
        i - regular flight index in the registry
        departure - the flight departure date
        Throws:
        java.lang.IllegalArgumentException - on null parameter or negative index
      • removeFlight

        public void removeFlight​(FlightId id)
        Remove a flight
        Parameters:
        id - the flight id
        Throws:
        java.lang.IllegalArgumentException - on null or non existent parameter
      • open

        public void open​(FlightId id)
        Open a flight to reservation
        Parameters:
        id - the flight id
        Throws:
        java.lang.IllegalArgumentException - on null or non existent parameter
      • close

        public void close​(FlightId id)
        Close a flight to reservation
        Parameters:
        id - the flight id
        Throws:
        java.lang.IllegalArgumentException - on null or non existent parameter
      • regularize

        public void regularize​(FlightId id)
        Regularize a flight : make a copy of the trip in the registry
        Parameters:
        id - the flight id
        Throws:
        java.lang.IllegalArgumentException - on null or non existent parameter
      • getRegulars

        public java.util.ArrayList<Trip> getRegulars()
        Getter
        Returns:
        a shallow copy of the list of regular trip
      • removeRegular

        public void removeRegular​(int i)
                           throws java.lang.IllegalArgumentException
        Remove a regular from the registry
        Parameters:
        i - regular flight index in the registry
        Throws:
        java.lang.IllegalArgumentException - on negative index
      • removeRegular

        public void removeRegular​(Trip t)
                           throws java.lang.IllegalArgumentException
        Remove a regular from the registry
        Parameters:
        t - the regular trip
        Throws:
        java.lang.IllegalArgumentException - null or non existent parameter
      • setRegulars

        public void setRegulars​(java.util.ArrayList<Trip> t)
        Setter
        Parameters:
        t - the regular trip list
        Throws:
        java.lang.IllegalArgumentException - null parameter
      • addRegulars

        public void addRegulars​(java.util.ArrayList<Trip> t)
        Add several regular trip
        Parameters:
        t - a list of trip
        Throws:
        java.lang.IllegalArgumentException - on null parameter
      • toString

        public java.lang.String toString()
        Redefinition of toString
        Overrides:
        toString in class java.lang.Object
        Returns:
        a string with name and prefix