Commit 88b5f145 authored by Ieva's avatar Ieva
Browse files

.

parent 365a013a
No preview for this file type
No preview for this file type
No preview for this file type
......@@ -13,6 +13,9 @@ import models.Passenger;
import models.VipPassenger;
import services.AirportService;
/*
* @author Ieva Bekmane 3ITB
*/
public class Main {
public static void main(String[] args) {
......
......@@ -6,6 +6,9 @@ import enums.AirportName;
import ifaces.INumberGenerator;
import utils.Verifiction;
/*
* @author Ieva Bekmane 3ITB
*/
public class Airport implements INumberGenerator{
private String airportNr;
private int capacity;
......
......@@ -5,33 +5,78 @@ import java.util.Random;
import ifaces.INumberGenerator;
import services.AirportService;
/*
* @author Ieva Bekmane 3ITB
*/
public class BoardingPass implements INumberGenerator{
private String boardingPassNr;
private short group;
private Passenger passenger;
private Seat seat;
/*
* @brief Returns passenger
*
* @param none
* @return passenger
*/
public Passenger getPassenger() {
return passenger;
}
/*
* @brief Allows to set passenger
*
* @param passenger
* @return none
*/
public void setPassenger(Passenger passenger) {
this.passenger = passenger;
}
/*
* @brief Returns seat
*
* @param none
* @return seat
*/
public Seat getSeat() {
return seat;
}
/*
* @brief Allows to set seat
*
* @param seat
* @return none
*/
public void setSeat(Seat seat) {
this.seat = seat;
}
/*
* @brief Returns boarding pass number
*
* @param none
* @return boardingPassNr
*/
public String getBoardingPassNr() {
return boardingPassNr;
}
/*
* @brief Argument constructor
*
* @param passenger
* @return none
*/
public BoardingPass(Passenger passenger) {
setPassenger(passenger);
generateNr();
generateGroupByPriority();
generateSeatByPriority();
}
/*
* @brief Group is generated by priority. VIP passenger group is 1, but regular passenger group is from 2 to 5
*
* @param none
* @return none
*/
public void generateGroupByPriority() {
Random rand = new Random();
for(Passenger p : AirportService.allPassenger) {
......@@ -42,6 +87,13 @@ public class BoardingPass implements INumberGenerator{
this.group = (short) (rand.nextInt(5 - 2) + 2);
}
}
/*
* @brief Seat is generated by priority. Seats of VIP passengers are from 1 to 3 in every column (a, b, c, d, e, f).
Seats of regular passengers are behind VIP passengers
*
* @param none
* @return none
*/
public void generateSeatByPriority() {
Random rand = new Random();
char[] rows = {'a', 'b', 'c', 'd', 'e', 'f'};
......@@ -59,6 +111,13 @@ public class BoardingPass implements INumberGenerator{
}
}
}
/*
* @brief Boarding pass number is created as follows: the first letter from passenger name +
* the first letter from surname + seat + group
*
* @param none
* @return none
*/
@Override
public void generateNr() {
StringBuilder sb = new StringBuilder();
......@@ -68,6 +127,12 @@ public class BoardingPass implements INumberGenerator{
sb.append(this.group);
this.boardingPassNr = sb.toString();
}
/*
* @brief Prints output
*
* @param none
* @return output
*/
@Override
public String toString() {
return "BoardingPass [boardingPassNr=" + boardingPassNr + ", group=" + group + ", passenger=" + passenger
......
......@@ -14,21 +14,57 @@ public class Flight implements INumberGenerator{
private Airport airportTo;
private static int flightNrCount = 0;
/*
* @brief Returns Flight number
*
* @param none
* @return flightNr
*/
public int getFlightNr() {
return flightNr;
}
/*
* @brief Returns Airport from where flight begins
*
* @param none
* @return airportFrom
*/
public Airport getAirportFrom() {
return airportFrom;
}
/*
* @brief Allows to set Airport from where flight begins
*
* @param airportFrom
* @return none
*/
public void setAirportFrom(Airport airportFrom) {
this.airportFrom = airportFrom;
}
/*
* @brief Returns Airport where flight ends
*
* @param none
* @return airportTo
*/
public Airport getAirportTo() {
return airportTo;
}
/*
* @brief Allows to set Airport where flight ends
*
* @param airportFrom
* @return none
*/
public void setAirportTo(Airport airportTo) {
this.airportTo = airportTo;
}
/*
* @brief Returns date of flight
*
* @param none
* @return dateAndTime
*/
public Date getDateAndTime() {
return dateAndTime;
}
......
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