Commit 70bf88cf authored by Amirhosein Rajabpour's avatar Amirhosein Rajabpour

third commit (documentations added)

parent 9ac7597c
File added
package com.TicketManagement; package com.TicketManagement;
import java.util.ArrayList; import java.util.ArrayList;
/**
* @author Amirhosein Rajabpour
* this class is airplane class and airplane are collaborated
* with seat and flight classes directly
*/
public class Airplane { public class Airplane {
private Seat seat; private Seat seat;
private String airplaneagency; private String airplaneagency;
...@@ -13,14 +17,35 @@ public class Airplane { ...@@ -13,14 +17,35 @@ public class Airplane {
this.model = model; this.model = model;
} }
/**
* arraylist of the reserved seats in an airplane
*/
ArrayList<Seat> seats = new ArrayList<>(); ArrayList<Seat> seats = new ArrayList<>();
/**
*
* @return all reserved seats in airplane
*/
public ArrayList<Seat> getSeats() { return seats; } public ArrayList<Seat> getSeats() { return seats; }
/**
*
* @return the model of aircraft
*/
public String getModel(){ return model;} public String getModel(){ return model;}
/**
*
* @return the airplane's agency (or airline)
*/
public String getAirplaneagency() { return airplaneagency; } public String getAirplaneagency() { return airplaneagency; }
/**
* this methode takes a seat and checks if that seat is already occupied or not
* and if the seat is free it reserves the seat otherwise nothing
* @param seat is the seat which should be checked
* @return if the seat is free it returns false and if the seat is occupied it returns true
*/
public boolean reserveSeat( Seat seat) { public boolean reserveSeat( Seat seat) {
if(seats.contains(seat)) if(seats.contains(seat))
......
package com.TicketManagement; package com.TicketManagement;
import java.util.ArrayList; import java.util.ArrayList;
/**
* @author Amirhosein Rajabpour
* this class is our passenger's class
*/
public class Customer { public class Customer {
private String name,lastname; private String name,lastname;
private int ID; private int ID;
...@@ -13,15 +16,31 @@ public class Customer { ...@@ -13,15 +16,31 @@ public class Customer {
this.lastname=lastname; this.lastname=lastname;
} }
/**
*
* @return our customer's ID
*/
public int getID() { return ID; } public int getID() { return ID; }
/**
*
* @returnour customer's name
*/
public String getName() { return name; } public String getName() { return name; }
/**
*
* @returnour customer's family 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); *
} * @param t which is a ticket that our customer wants to buy
* customer buy the ticket ad the seat will be booked
*/
public void buyTicket(Ticket t){
tickets.add(t);
t.getFlight().getAirplane().reserveSeat(t.getSeat());
}
} }
package com.TicketManagement; package com.TicketManagement;
import java.util.Date; import java.util.Date;
/**
* @author Amirhosein Rajabpour
*
* flight class represents fields related to flights
*/
public class Flight { public class Flight {
private Date date; private Date date;
private String destination; private String destination;
...@@ -12,35 +16,82 @@ public class Flight { ...@@ -12,35 +16,82 @@ public class Flight {
private String model; private String model;
public Flight(Date date,int flightNumber,String destination,String source,Airplane airplane){ public Flight(Date date,int flightNumber,String destination,String source,Airplane airplane){
this.date=date; this.date = date;
this.source=source; 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.company = airplane.getAirplaneagency();
this.model = airplane.getModel(); this.model = airplane.getModel();
} }
/**
*
* @return flight number
*/
public int getFlightNumber() { public int getFlightNumber() {
return flightNumber; return flightNumber;
} }
/**
*
* @return source of the flight
*/
public String getSource() { public String getSource() {
return source; return source;
} }
/**
*
* @return object of airplane
*/
public Airplane getAirplane() { public Airplane getAirplane() {
return airplane; return airplane;
} }
/**
*
* @return date of the flight
*/
public Date getDate() { public Date getDate() {
return date; return date;
} }
/**
*
* @return destination of the flight
*/
public String getDestination() { public String getDestination() {
return destination; return destination;
} }
/**
*
* @return airplain's company (airline)
*/
public String getCompany(){ return company;} public String getCompany(){ return company;}
/**
*
* @return model of the Aircraft
*/
public String getModel(){ return model;}
/**
*
* @param f which is a flight object
* shows details of a specific flight
*/
public void displayFlight(Flight f){
System.out.println(f.getDate());
System.out.println(f.getDestination());
System.out.println(f.getCompany());
System.out.println(f.getModel());
System.out.println(f.getFlightNumber());
}
} }
package com.TicketManagement; package com.TicketManagement;
/**
* @author Amirhosein Rajabpour
*
* this class indicates a seat and it's features for us
*/
public class Seat { public class Seat {
private int ID; private int ID;
private String Type; private String Type;
...@@ -10,15 +15,32 @@ public class Seat { ...@@ -10,15 +15,32 @@ public class Seat {
this.ID=ID; this.ID=ID;
} }
/**
*
* @return seat number
*/
public int getID() { public int getID() {
return ID; return ID;
} }
/**
*
* @return type of the seat which can be business class, first class or economic class
*/
public String getType() { public String getType() {
return Type; return Type;
} }
/**
*
* @return the ID of the user who has reserved this seat already
*/
public int getUserID(){ return userID;} public int getUserID(){ return userID;}
/**
*
* @param u is our user ID who booked the seat and set this ID
*/
public void setUser(int u) { userID = u; } public void setUser(int u) { userID = u; }
} }
package com.TicketManagement; package com.TicketManagement;
/**
* @author Amirhosein Rajabpour
*
* this class is for simulating a ticket and some related parameters
*/
public class Ticket { public class Ticket {
private int seatnumber; private int seatnumber;
private int flightnumber; private int flightnumber;
...@@ -15,23 +20,47 @@ public class Ticket { ...@@ -15,23 +20,47 @@ public class Ticket {
this.food = food; this.food = food;
} }
/**
* each passenger can have a specific amount of luggage
* @return the passenger's luggage weight
*/
public int getLuggageWeight() { public int getLuggageWeight() {
return LuggageWeight; return LuggageWeight;
} }
/**
* each passenger can have a meal
* @return passenger's food
*/
public String getFood() { public String getFood() {
return food; return food;
} }
/**
*
* @return passenger's flight number ( which is obviously mentioned in the ticket)
*/
public int getFlightnumber() { public int getFlightnumber() {
return flightnumber; return flightnumber;
} }
/**
*
* @return passenger's seat number
*/
public int getSeatnumber() { public int getSeatnumber() {
return seatnumber; return seatnumber;
} }
/**
*
* @return the object of passenger's flight
*/
public Flight getFlight() {return flight;} public Flight getFlight() {return flight;}
/**
*
* @return the object of passenger's seat
*/
public Seat getSeat(){ return seat;} public Seat getSeat(){ return seat;}
} }
package com.TicketManagement; package com.TicketManagement;
import java.util.ArrayList; import java.util.ArrayList;
/**
* @author Amirhosein Rajabpour
*
* this class manages the booking flight system
*/
public class TicketManagement { public class TicketManagement {
private ArrayList<Flight> flights=new ArrayList<Flight>(); /**
* an arraylist out of Flight objects which aggregates all flights
*/
private ArrayList<Flight> flights = new ArrayList<Flight>();
/**
*
* @return all flights
*/
public ArrayList<Flight> getFlights() { public ArrayList<Flight> getFlights() {
return flights; return flights;
} }
/**
*
* @param flight
* takes an specific flight object and remove it from our flight array list
*/
public void removeFlight(Flight flight){flights.remove(flight);} public void removeFlight(Flight flight){flights.remove(flight);}
/**
*
* @param flight
* takes a flight and add it to flight array list
*/
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