Commit 499109b3 authored by unknown's avatar unknown

ehtemalan akharish

parent 60ec98b3
...@@ -8,9 +8,14 @@ public class Airplane { ...@@ -8,9 +8,14 @@ public class Airplane {
public Airplane(String type , ArrayList<Seat> seats){ public Airplane(String type , ArrayList<Seat> seats){
this.type = type ; this.type = type ;
this.freeSeats = seats ;
this.seats = seats ; this.seats = seats ;
} }
public String getType() {
return type;
}
public ArrayList<Seat> getSeats(){ public ArrayList<Seat> getSeats(){
return seats ; return seats ;
} }
...@@ -19,7 +24,14 @@ public class Airplane { ...@@ -19,7 +24,14 @@ public class Airplane {
return freeSeats ; return freeSeats ;
} }
public void reserveSeat(Seat seat){ public void reserveSeat(Seat seat ,Customer customer){
for (Seat s : seats
) {
if (s == seat) {
s.setCustomer(customer);
}
}
this.freeSeats.remove(seat);
} }
......
import java.util.ArrayList;
public class Customer { public class Customer {
private String name ; private String name ;
private String lastname ; private String lastname ;
private int ID ; private int ID ;
ArrayList<Ticket> tickets = null;
public Customer(String name , String lastname , int ID){ public Customer(String name , String lastname , int ID){
this.name = name ; this.name = name ;
...@@ -10,9 +13,25 @@ public class Customer { ...@@ -10,9 +13,25 @@ public class Customer {
this.ID = ID ; this.ID = ID ;
} }
public void reserve(Flight flight , Seat seat , Boolean hasFood , int weight){ public String getName() {
return name;
}
public String getLastname(){
return lastname ;
}
public int getID() {
return ID;
} }
public ArrayList<Ticket> getTickets() {
return tickets;
}
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);
}
} }
import java.util.ArrayList;
public class Flight { public class Flight {
private Airplane airplane ; private Airplane airplane ;
private int ID ;
private String source ; private String source ;
private String dest ; private String dest ;
private String company ; private String company ;
private int no ;
private String type ;
private int date ;
public Flight(int ID , String source , String dest , String company){ public Flight(Airplane airplane , String source , String dest , String company , String type , int no , int date){
this.ID = ID ; this.airplane = airplane ;
this.source = source ; this.source = source ;
this.dest = dest ; this.dest = dest ;
this.company = company ; this.company = company ;
this.type = type ;
this.no = no ;
this.date = date ;
} }
public int getID(){ public Airplane getAirplane(){
return getID() ; return airplane ;
} }
public String getSource(){ public String getSource(){
...@@ -26,13 +33,33 @@ public class Flight { ...@@ -26,13 +33,33 @@ public class Flight {
return dest ; return dest ;
} }
public Airplane getAirplane(){
return airplane ;
}
public String getCompany(){ public String getCompany(){
return company ; return company ;
} }
public String getType(){
return type ;
}
public int getNo(){
return no ;
}
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, Customer customer) {
this.airplane.reserveSeat(seat, customer);
}
} }
...@@ -2,10 +2,10 @@ public class Seat { ...@@ -2,10 +2,10 @@ public class Seat {
private String type ; private String type ;
private Customer customer ; private Customer customer ;
private int num ; private int no ;
public Seat(int num , String type){ public Seat(int no , String type){
this.num = num ; this.no = no ;
this.type = type ; this.type = type ;
} }
...@@ -21,8 +21,8 @@ public class Seat { ...@@ -21,8 +21,8 @@ public class Seat {
return type; return type;
} }
public int getNum() { public int getNo() {
return num; return no;
} }
} }
...@@ -5,16 +5,29 @@ public class System { ...@@ -5,16 +5,29 @@ public class System {
private ArrayList<Flight> flights ; private ArrayList<Flight> flights ;
public System(){ public System(ArrayList<Flight> flights){
this.flights = flights ;
} }
public void addFlight(Flight flight){ public void addFlight(Flight flight){
this.flights.add() ; this.flights.add(flight) ;
} }
public void removeFlight(Flight flight){ 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 , Customer customer) {
for (Flight f : flights
) {
if (f == flight) {
f.reserve(seat , customer);
}
}
}
} }
public class Ticket { public class Ticket {
private int seatNum ; private int seatNo ;
private int flightNum ; private int flightNo ;
private int luggageWeight ; private int luggageWeight ;
private Boolean foodStatus ; private Boolean foodStatus ;
public Ticket(int seatNum , int flightNum , int luggageWeight , boolean foodStatus){ public Ticket(int seatNo , int flightNum , int luggageWeight , boolean foodStatus){
this.seatNum = seatNum ; this.seatNo = seatNo ;
this.flightNum = flightNum ; this.flightNo = flightNum ;
this.luggageWeight = luggageWeight ; this.luggageWeight = luggageWeight ;
this.foodStatus = foodStatus ; this.foodStatus = foodStatus ;
} }
public int getSeatNum(){ public int getSeatNo(){
return seatNum ; return seatNo ;
} }
public int getFlightNum(){ public int getFlightNo(){
return flightNum ; return flightNo ;
} }
public int getLuggageWeight(){ public int getLuggageWeight(){
......
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