Commit 70ce7380 authored by 9731087's avatar 9731087

probably the last on

parent 6dbfdcec
import java.util.ArrayList;
/**
* airplane of the flight
*/
public class Airplane {
private String type;
private ArrayList<Seat> seats;
private ArrayList<Seat> freeSeats;
/**
* constructs an airplane
*
* @param seats
* @param type
*/
public Airplane(ArrayList<Seat> seats, String type) {
this.seats = seats;
this.freeSeats = seats;
this.type = type;
}
/**
* returns free seats
*
* @return
*/
public ArrayList<Seat> getFreeSeats() {
return freeSeats;
}
/**
* returns all of seats
*
* @return
*/
public ArrayList<Seat> getSeats() {
return seats;
}
/**
* returns the type of seat
*
* @return
*/
public String getType() {
return type;
}
/**
* reserves a seat for a passenger on this airplane
*
* @param seat
* @param passenger
*/
public void reserve(Seat seat, Passenger passenger) {
for (Seat s : seats
) {
......
import java.util.ArrayList;
/**
* an available flight
*/
public class Flight {
private Airplane airplane;
......@@ -10,6 +13,17 @@ public class Flight {
private int No;
private int date;
/**
* constructs a flight
*
* @param airplane
* @param company
* @param destination
* @param origin
* @param type
* @param No
* @param date
*/
public Flight(Airplane airplane, String company, String destination, String origin, String type, int No, int date) {
this.airplane = airplane;
this.company = company;
......@@ -20,42 +34,93 @@ public class Flight {
this.date = date;
}
/**
* returns type of this flight
*
* @return
*/
public String getType() {
return type;
}
/**
* returns number of this flight
*
* @return
*/
public int getNo() {
return No;
}
/**
* returns airplane of this flight
*
* @return
*/
public Airplane getAirplane() {
return airplane;
}
/**
* returns company of this flight
*
* @return
*/
public String getCompany() {
return company;
}
/**
* returns destination of this flight
*
* @return
*/
public String getDestination() {
return destination;
}
/**
* returns origin of this flight
*
* @return
*/
public String getOrigin() {
return origin;
}
/**
* returns date of this flight
*
* @return
*/
public int getDate() {
return date;
}
/**
* returns free seats on this flight
*
* @return
*/
public ArrayList<Seat> getFreeSeats() {
return this.airplane.getFreeSeats();
}
/**
* returns total seats of this flight
*
* @return
*/
public ArrayList<Seat> getSeats() {
return this.airplane.getSeats();
}
/**
* reserves a seat for a passenger
*
* @param seat
* @param passenger
*/
public void reserve(Seat seat, Passenger passenger) {
this.airplane.reserve(seat, passenger);
}
......
import java.util.ArrayList;
/**
* passenger of the flight
*/
public class Passenger {
private String name;
......@@ -7,17 +10,37 @@ public class Passenger {
int ID;
ArrayList<Ticket> tickets = null;
/**
* constructs a passenger
*
* @param name
* @param lastName
* @param ID
*/
public Passenger(String name, String lastName, int ID) {
this.name = name;
this.lastName = lastName;
this.ID = ID;
}
/**
* reserves a ticket for this passenger
*
* @param flight
* @param seat
* @param hasFood
* @param weight
*/
public void reserve(Flight flight, Seat seat, Boolean hasFood, int weight) {
Ticket ticket = new Ticket(seat.getNo(), flight.getNo(), weight, hasFood);
this.tickets.add(ticket);
}
/**
* returns passenger's tickets
*
* @return
*/
public ArrayList<Ticket> getTickets() {
return tickets;
}
......
/**
* seat of the airplane
*/
public class Seat {
private int No;
private String type;
private Passenger passenger;
public Seat(int No, String type){
/**
* constructs a seat
*
* @param No
* @param type
*/
public Seat(int No, String type) {
this.No = No;
this.type = type;
}
/**
* returns seats number
*
* @return
*/
public int getNo() {
return No;
}
/**
* return seats type
*
* @return
*/
public String getType() {
return type;
}
/**
* relates a passenger to this seat
*
* @param passenger
*/
public void setPassenger(Passenger passenger) {
this.passenger = passenger;
}
/**
* returns passenger who reserved this seat
*
* @return
*/
public Passenger getPassenger() {
return passenger;
}
......
import java.util.ArrayList;
/**
* the manager of all flights
*/
public class SystemManagement {
private ArrayList<Flight> flights;
/**
* constructs a system management
*
* @param flights
*/
public SystemManagement(ArrayList<Flight> flights) {
this.flights = flights;
}
/**
* adds a flight to the flight list
*
* @param flight
*/
public void addFlight(Flight flight) {
this.flights.add(flight);
}
/**
* removes a flight from the flight list
*
* @param flight
*/
public void removeFlight(Flight flight) {
this.flights.remove(flight);
}
/**
* returns all of the flights
*
* @return
*/
public ArrayList<Flight> getFlights() {
return flights;
}
/**
* reserves a seat from a flight for a passenger
*
* @param flight
* @param seat
* @param passenger
*/
public void reserve(Flight flight, Seat seat, Passenger passenger) {
for (Flight f : flights
) {
......
/**
* reservation ticket
*/
public class Ticket {
private int SeatNo;
......@@ -5,25 +8,53 @@ public class Ticket {
private int baggageWeight;
private Boolean foodStatus;
public Ticket(int seatNo, int flightNo, int baggageWeight, Boolean foodStatus){
/**
* constructs a ticket
*
* @param seatNo
* @param flightNo
* @param baggageWeight
* @param foodStatus
*/
public Ticket(int seatNo, int flightNo, int baggageWeight, Boolean foodStatus) {
this.SeatNo = seatNo;
this.flightNo = flightNo;
this.baggageWeight = baggageWeight;
this.foodStatus = foodStatus;
}
/**
* returns the food status
*
* @return
*/
public Boolean getFoodStatus() {
return foodStatus;
}
/**
* returns the baggage weight
*
* @return
*/
public int getBaggageWeight() {
return baggageWeight;
}
/**
* returns the flight number
*
* @return
*/
public int getFlightNo() {
return flightNo;
}
/**
* returns the seat nomber
*
* @return
*/
public int getSeatNo() {
return SeatNo;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment