Commit 499109b3 authored by unknown's avatar unknown

ehtemalan akharish

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