package com.company;

import java.util.ArrayList;

/**
 * This class shows a flights with all of its properties
 * @author Seyedeh Fatemeh Ahmadzadeh
 * @version 1.0
 * @since 2019 - 3 - 5
 */

public class Flight {
    private String date;
    private String time;
    private int flightNo;
    private String source;
    private String destination;
    private Airplain airplain;
    private ArrayList<Seat> allseats = new ArrayList<Seat>();
    private ArrayList<Seat> emptyTseats = new ArrayList<Seat>();
    private String airline;

    public Flight(String date , String time , int flightNo , String source , String destination , Airplain airplain , String airline){
        this.date = date;
        this.time = time;
        this.flightNo = flightNo;
        this.destination = destination;
        this.source = source;
        this.airplain = airplain;
        this.airline = airline;
        for(Seat s : airplain.getSeats()){
            allseats.add(s);
            emptyTseats.add(s);
            s.setReserveCondition("empty");
        }
    }

    /**
     * This method is used for reserving a seat and remove that seat from the list of empty seats of the flight.
     * @param seatNum is number of the seat that a customer wants to reserve.
     */

    public void setSeats(int seatNum){
        for(Seat s : allseats){
            if(s.getSeatNumber() == seatNum){
                emptyTseats.remove(s);
                break;
            }
        }
    }

    /**
     * This method is used to know the flight number in other classes.
     * @return the number of flight.
     */

    public int getFlightNo(){
        return flightNo;
    }

    /**
     * This method is used to know the flight time in other classes.
     * @return the time of the flight.
     */

    public String getTime(){
        return time;
    }

    /**
     * This method is used to know the flight date in other classes.
     * @return the date of the flight.
     */

    public String getDate(){
        return date;
    }

    /**
     * This method is used to know destination in other classes.
     * @return the destination of the flight.
     */

    public String getDestination(){
        return destination;
    }

    /**
     * This method is used to know the flight source in other classes.
     * @return the source of the flight.
     */

    public String getSource(){
        return source;
    }

    /**
     * This method is used to know the seats of this of this flight in other classes.
     * @return all of the seats of this flight
     */

    public ArrayList<Seat> getAllseats(){
        return allseats;
    }

    /**
     * This method is used to know the empty seats of this of this flight in other classes.
     * @return the empty seats of this flight.
     */

    public ArrayList<Seat> getEmptyTseats(){
        return emptyTseats;
    }

    /**
     * This method is used to know the type of airplane of this flight in other classes.
     * @return the type of airplane of this flight.
     */

    public String getAirplaineKind(){
        return airplain.getAirplaineKind();
    }

    /**
     * This method is used to know the flight airline in other classes.
     * @return the flight airline.
     */

    public String getAirline(){
        return airline;
    }
}
