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

third commit (documentations added)

parent 9ac7597c
File added
package com.TicketManagement;
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 {
private Seat seat;
private String airplaneagency;
......@@ -13,14 +17,35 @@ public class Airplane {
this.model = model;
}
/**
* arraylist of the reserved seats in an airplane
*/
ArrayList<Seat> seats = new ArrayList<>();
/**
*
* @return all reserved seats in airplane
*/
public ArrayList<Seat> getSeats() { return seats; }
/**
*
* @return the model of aircraft
*/
public String getModel(){ return model;}
/**
*
* @return the airplane's agency (or airline)
*/
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) {
if(seats.contains(seat))
......
package com.TicketManagement;
import java.util.ArrayList;
/**
* @author Amirhosein Rajabpour
* this class is our passenger's class
*/
public class Customer {
private String name,lastname;
private int ID;
......@@ -13,15 +16,31 @@ public class Customer {
this.lastname=lastname;
}
/**
*
* @return our customer's ID
*/
public int getID() { return ID; }
/**
*
* @returnour customer's name
*/
public String getName() { return name; }
/**
*
* @returnour customer's family name
*/
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;
import java.util.Date;
/**
* @author Amirhosein Rajabpour
*
* flight class represents fields related to flights
*/
public class Flight {
private Date date;
private String destination;
......@@ -12,35 +16,82 @@ public class Flight {
private String model;
public Flight(Date date,int flightNumber,String destination,String source,Airplane airplane){
this.date=date;
this.source=source;
this.airplane=airplane;
this.destination=destination;
this.flightNumber=flightNumber;
this.date = date;
this.source = source;
this.airplane = airplane;
this.destination = destination;
this.flightNumber = flightNumber;
this.company = airplane.getAirplaneagency();
this.model = airplane.getModel();
}
/**
*
* @return flight number
*/
public int getFlightNumber() {
return flightNumber;
}
/**
*
* @return source of the flight
*/
public String getSource() {
return source;
}
/**
*
* @return object of airplane
*/
public Airplane getAirplane() {
return airplane;
}
/**
*
* @return date of the flight
*/
public Date getDate() {
return date;
}
/**
*
* @return destination of the flight
*/
public String getDestination() {
return destination;
}
/**
*
* @return airplain's company (airline)
*/
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;
/**
* @author Amirhosein Rajabpour
*
* this class indicates a seat and it's features for us
*/
public class Seat {
private int ID;
private String Type;
......@@ -10,15 +15,32 @@ public class Seat {
this.ID=ID;
}
/**
*
* @return seat number
*/
public int getID() {
return ID;
}
/**
*
* @return type of the seat which can be business class, first class or economic class
*/
public String getType() {
return Type;
}
/**
*
* @return the ID of the user who has reserved this seat already
*/
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; }
}
package com.TicketManagement;
/**
* @author Amirhosein Rajabpour
*
* this class is for simulating a ticket and some related parameters
*/
public class Ticket {
private int seatnumber;
private int flightnumber;
......@@ -15,23 +20,47 @@ public class Ticket {
this.food = food;
}
/**
* each passenger can have a specific amount of luggage
* @return the passenger's luggage weight
*/
public int getLuggageWeight() {
return LuggageWeight;
}
/**
* each passenger can have a meal
* @return passenger's food
*/
public String getFood() {
return food;
}
/**
*
* @return passenger's flight number ( which is obviously mentioned in the ticket)
*/
public int getFlightnumber() {
return flightnumber;
}
/**
*
* @return passenger's seat number
*/
public int getSeatnumber() {
return seatnumber;
}
/**
*
* @return the object of passenger's flight
*/
public Flight getFlight() {return flight;}
/**
*
* @return the object of passenger's seat
*/
public Seat getSeat(){ return seat;}
}
package com.TicketManagement;
import java.util.ArrayList;
/**
* @author Amirhosein Rajabpour
*
* this class manages the booking flight system
*/
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() {
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);}
/**
*
* @param flight
* takes a flight and add it to flight array list
*/
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