Commit 70ce7380 authored by 9731087's avatar 9731087

probably the last on

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