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

half commit 2

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