Commit 6dbfdcec authored by 9731087's avatar 9731087

commit

parent b1777934
......@@ -8,6 +8,7 @@ public class Airplane {
public Airplane(ArrayList<Seat> seats, String type) {
this.seats = seats;
this.freeSeats = seats;
this.type = type;
}
......@@ -19,7 +20,17 @@ public class Airplane {
return seats;
}
public void reserve(Seat seat) {
public String getType() {
return type;
}
public void reserve(Seat seat, Passenger passenger) {
for (Seat s : seats
) {
if (s == seat) {
s.setPassenger(passenger);
}
}
this.freeSeats.remove(seat);
}
}
import java.util.ArrayList;
public class Flight {
private Airplane airplane;
......@@ -8,7 +10,7 @@ public class Flight {
private int No;
private int 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.company = company;
this.destination = destination;
......@@ -45,4 +47,16 @@ public class Flight {
public int getDate() {
return date;
}
public ArrayList<Seat> getFreeSeats() {
return this.airplane.getFreeSeats();
}
public ArrayList<Seat> getSeats() {
return this.airplane.getSeats();
}
public void reserve(Seat seat, Passenger passenger) {
this.airplane.reserve(seat, passenger);
}
}
import java.util.ArrayList;
public class Passenger {
private String name;
private String lastName;
int ID;
ArrayList<Ticket> tickets = null;
public Passenger(String name, String lastName, int ID){
public Passenger(String name, String lastName, int ID) {
this.name = name;
this.lastName = lastName;
this.ID = ID;
}
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);
this.tickets.add(ticket);
}
public ArrayList<Ticket> getTickets() {
return tickets;
}
}
......@@ -4,8 +4,8 @@ public class SystemManagement {
private ArrayList<Flight> flights;
public SystemManagement() {
public SystemManagement(ArrayList<Flight> flights) {
this.flights = flights;
}
public void addFlight(Flight flight) {
......@@ -13,6 +13,19 @@ public class SystemManagement {
}
public void removeFlight(Flight flight) {
this.flights.remove(flight);
this.flights.remove(flight);
}
public ArrayList<Flight> getFlights() {
return flights;
}
public void reserve(Flight flight, Seat seat, Passenger passenger) {
for (Flight f : flights
) {
if (f == flight) {
f.reserve(seat, passenger);
}
}
}
}
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