Commit 9ac7597c authored by Amirhosein Rajabpour's avatar Amirhosein Rajabpour

half commit 2

parent e5464570
package com.TicketManagement; package com.TicketManagement;
import java.util.ArrayList;
public class Airplane { public class Airplane {
private int seats; private Seat seat;
private String airplaneagency; private String airplaneagency;
public Airplane(int seats,String airplaneagency){ private String model;
this.seats=seats;
public Airplane(Seat seat,String airplaneagency,String model){
this.seat=seat;
this.airplaneagency=airplaneagency; this.airplaneagency=airplaneagency;
this.model = model;
} }
public int getSeats() {
return seats;
}
public String getAirplaneagency() { ArrayList<Seat> seats = new ArrayList<>();
return airplaneagency;
public ArrayList<Seat> getSeats() { return seats; }
public String getModel(){ return model;}
public String getAirplaneagency() { return airplaneagency; }
public boolean reserveSeat( Seat seat) {
if(seats.contains(seat))
{
System.out.println("seat is reserved");
return false;
}
else
{
seats.add(seat);
return true;
}
} }
} }
...@@ -6,28 +6,22 @@ public class Customer { ...@@ -6,28 +6,22 @@ public class Customer {
private String name,lastname; private String name,lastname;
private int ID; private int ID;
private ArrayList<Ticket> tickets= new ArrayList<Ticket>(); private ArrayList<Ticket> tickets= new ArrayList<Ticket>();
public Customer(String name,String lastname,int ID){ public Customer(String name,String lastname,int ID){
this.name=name; this.name=name;
this.ID=ID; this.ID=ID;
this.lastname=lastname; this.lastname=lastname;
} }
public void addTicket(Ticket ticket){
tickets.add(ticket);
}
public ArrayList<Ticket> getTickets() { public int getID() { return ID; }
return tickets;
}
public int getID() { public String getName() { return name; }
return ID;
}
public String getName() { public String getLastname() { return lastname; }
return name;
}
public String getLastname() { public void addTicket(Ticket t){ tickets.add(t);
return lastname; t.getFlight().getAirplane().reserveSeat(t.getSeat);
} }
} }
...@@ -7,21 +7,27 @@ public class Flight { ...@@ -7,21 +7,27 @@ public class Flight {
private String destination; private String destination;
private Airplane airplane; private Airplane airplane;
private int flightNumber; private int flightNumber;
private String start; private String source;
public Flight(Date date,int flightNumber,String destination,String start,Airplane airplane){ private String company;
private String model;
public Flight(Date date,int flightNumber,String destination,String source,Airplane airplane){
this.date=date; this.date=date;
this.start=start; this.source=source;
this.airplane=airplane; this.airplane=airplane;
this.destination=destination; this.destination=destination;
this.flightNumber=flightNumber; this.flightNumber=flightNumber;
this.company = airplane.getAirplaneagency();
this.model = airplane.getModel();
} }
public int getFlightNumber() { public int getFlightNumber() {
return flightNumber; return flightNumber;
} }
public String getStart() { public String getSource() {
return start; return source;
} }
public Airplane getAirplane() { public Airplane getAirplane() {
return airplane; return airplane;
} }
...@@ -30,9 +36,11 @@ public class Flight { ...@@ -30,9 +36,11 @@ public class Flight {
return date; return date;
} }
public String getDestination() { public String getDestination() {
return destination; return destination;
} }
public String getCompany(){ return company;}
} }
...@@ -2,22 +2,23 @@ package com.TicketManagement; ...@@ -2,22 +2,23 @@ package com.TicketManagement;
public class Seat { public class Seat {
private int ID; private int ID;
private String kind; private String Type;
private int userID; private int userID;
public Seat(int ID,String kind,int userID){ public Seat(int ID,String Type){
this.kind=kind; this.Type=Type;
this.ID=ID; this.ID=ID;
this.userID = userID;
} }
public int getID() { public int getID() {
return ID; return ID;
} }
public String getKind() { public String getType() {
return kind; return Type;
} }
public int getUserID(){ return userID;} public int getUserID(){ return userID;}
public void setUser(int u) { userID = u; }
} }
...@@ -3,21 +3,24 @@ package com.TicketManagement; ...@@ -3,21 +3,24 @@ package com.TicketManagement;
public class Ticket { public class Ticket {
private int seatnumber; private int seatnumber;
private int flightnumber; private int flightnumber;
private int cargo; private int LuggageWeight;
private String meal; private String food;
public Ticket(int seatnumber,int flightnumber,int cargo,String meal){ Flight flight;
this.flightnumber=flightnumber; Seat seat;
this.seatnumber=seatnumber;
this.cargo=cargo; public Ticket(Seat seat,Flight flight,int LuggageWeight,String food){
this.meal=meal; this.flightnumber = flight.getFlightNumber();
this.seatnumber = seat.getID();
this.LuggageWeight = LuggageWeight;
this.food = food;
} }
public int getCargo() { public int getLuggageWeight() {
return cargo; return LuggageWeight;
} }
public String getMeal() { public String getFood() {
return meal; return food;
} }
public int getFlightnumber() { public int getFlightnumber() {
...@@ -27,4 +30,8 @@ public class Ticket { ...@@ -27,4 +30,8 @@ public class Ticket {
public int getSeatnumber() { public int getSeatnumber() {
return seatnumber; return seatnumber;
} }
public Flight getFlight() {return flight;}
public Seat getSeat(){ return seat;}
} }
...@@ -4,26 +4,11 @@ import java.util.ArrayList; ...@@ -4,26 +4,11 @@ import java.util.ArrayList;
public class TicketManagement { public class TicketManagement {
private ArrayList<Flight> flights=new ArrayList<Flight>(); private ArrayList<Flight> flights=new ArrayList<Flight>();
private ArrayList<Customer> customers= new ArrayList<Customer>();
private ArrayList<Airplane> airplanes= new ArrayList<Airplane>();
public ArrayList<Flight> getFlights() { public ArrayList<Flight> getFlights() {
return flights; return flights;
} }
public void removeFlight(Flight flight){flights.remove(flight);}
public ArrayList<Customer> getCustomers() {
return customers;
}
public ArrayList<Airplane> getAirplanes() {
return airplanes;
}
public void addAirplane(Airplane airplane){
airplanes.add(airplane);
}
public void addCustomer(Customer customer){
customers.add(customer);
}
public void addFlight(Flight flight){ public void addFlight(Flight flight){
flights.add(flight); flights.add(flight);
} }
......
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