Commit 0cf73878 authored by Ieva's avatar Ieva
Browse files

.

parent 88b5f145
......@@ -6,7 +6,5 @@
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="C:/Users/ieva1/Downloads/HomeWork01TeacherTest (1).jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5"/>
<classpathentry kind="output" path="bin"/>
</classpath>
No preview for this file type
No preview for this file type
No preview for this file type
......@@ -22,28 +22,106 @@ public class Main {
AirportService services = new AirportService();
services.addNewPassenger("Janis", "Liepins", Nationality.LATVIAN, IdenType.PASSPORT, "AS12345", true, "No extra needs");
services.addNewPassenger("Liene", "Kalnina", Nationality.ESTONIAN, IdenType.IDCARD, "GH12345", false, "No extra needs");
services.addNewVipPassenger("Baiba", "Jauka", Nationality.ITALIAN, IdenType.PASSPORT, "ER12345", true, "No extra needs", "ZX12345");
services.addNewVipPassenger("Zane", "Berzina", Nationality.LATVIAN, IdenType.PASSPORT, "LM12345", true, "No extra needs", "BN12345");
/*====================================PASSENGERS======================================*/
Passenger p1 = new Passenger("Janis", "Liepins", "AS12345", Nationality.LATVIAN, IdenType.PASSPORT, true, "No extra needs");
Passenger p2 = new Passenger("Liene", "Kalnina", "GH12345", Nationality.ESTONIAN, IdenType.IDCARD, false, "No extra needs");
VipPassenger vip1 = new VipPassenger("Baiba", "Jauka", "ER12345", Nationality.ITALIAN, IdenType.PASSPORT, true, "No extra needs", "ZX12345");
VipPassenger vip2 = new VipPassenger("Zane", "Berzina", "LM12345", Nationality.LATVIAN, IdenType.PASSPORT, true, "No extra needs", "BN12345");
AirportService.allPassenger.add(p1);
AirportService.allPassenger.add(p2);
AirportService.allPassenger.add(vip1);
AirportService.allPassenger.add(vip2);
services.addNewPassenger("Katrina", "Zarina", Nationality.LATVIAN, IdenType.IDCARD, "DF12345", false, "No extra needs");
services.addNewVipPassenger("Juris", "Pakalns", Nationality.ITALIAN, IdenType.IDCARD, "DE12345", true, "No extra needs", "VZ12345");
services.addNewAirport(AirportName.BARSELONA, 2000);
services.addNewAirport(AirportName.OSLO, 3000);
System.out.println("---------------------Passengers-------------------------");
for(Passenger p : AirportService.allPassenger) {
System.out.println(p);
}
System.out.println("--------------------------------------------------------");
System.out.println("Delete passenger by name and surname: " + services.deletePassengerByNameAndSurname("Baiba", "Jauka"));
System.out.println("Delete passenger by number: " + services.deletePassengerByIdentNr("AS12345"));
System.out.println("Delete VipPassenger by vipNr: " + services.deleteVipPassengerByVipNr(2));
System.out.println("---------------Passengers after delete------------------");
for(Passenger p : AirportService.allPassenger) {
System.out.println(p);
}
System.out.println("--------------------------------------------------------");
/* =======================AIRPORTS======================*/
Airport a1 = new Airport(2000, AirportName.BARSELONA);
Airport a2 = new Airport(3000, AirportName.OSLO);
AirportService.allAirports.add(a1);
AirportService.allAirports.add(a2);
services.addNewAirport(AirportName.RIGA, 4000);
services.addNewAirport(AirportName.TALLINN, 2500);
Date d1 = new Date(2020, 10, 10, 9, 00);
System.out.println("---------------------Airports---------------------------");
for(Airport a : AirportService.allAirports) {
System.out.println(a);
}
System.out.println("--------------------------------------------------------");
System.out.println("Delete airport by number:" + services.deleteAirportByAirportNr(AirportService.allAirports.get(0).getAirportNr()));
System.out.println("Delete airport by name:" + services.deleteAirportByAirportName(AirportName.RIGA));
System.out.println("---------------Airports after delete---------------------");
for(Airport a : AirportService.allAirports) {
System.out.println(a);
}
System.out.println("--------------------------------------------------------");
/*============================BOARDING PASSES===================================*/
BoardingPass b1 = new BoardingPass(p1);
BoardingPass b2 = new BoardingPass(p2);
BoardingPass b3 = new BoardingPass(vip1);
BoardingPass b4 = new BoardingPass(vip2);
/*Date d1 = new Date(2020, 10, 10, 9, 00);
Date d2 = new Date(2020, 11, 12, 10, 00);
Flight f1 = new Flight(d1, (byte) 3, AirportService.allAirports.get(0), AirportService.allAirports.get(1));
Flight f2 = new Flight(d2, (byte) 3, AirportService.allAirports.get(0), AirportService.allAirports.get(2));
AirportService.allFlights.add(f1);
AirportService.allFlights.add(f2);
for(Passenger p : AirportService.allPassenger) {
System.out.println(p);
}
services.addNewBoardingPassByObject(f1, AirportService.allPassenger.get(0));
services.addNewBoardingPassByObject(f1, AirportService.allPassenger.get(2));
services.addNewBoardingPassByObject(f1, AirportService.allPassenger.get(3));
for(BoardingPass bp : AirportService.allBoardingPasses) {
System.out.println(bp);
}
System.out.println("--------------------------------------------------------");
services.addNewBoardingPassByObject(f1, AirportService.allPassenger.get(2));
for(BoardingPass bp : AirportService.allBoardingPasses) {
System.out.println(bp);
}
//services.showAppFlightsFromAirport(AirportName.BARSELONA);
services.showOnlyVIPPassengersInFlight(AirportName.BARSELONA, 0);*/
}
}
......@@ -96,6 +96,6 @@ public class Airport implements INumberGenerator{
*/
@Override
public String toString() {
return "Airport [airportNr: " + airportNr + ", capacity: " + capacity + ", airportName: " + airportName + "]";
return "Airport: " + airportName + ", capacity: " + capacity + ", airportNr: " + airportNr;
}
}
......@@ -5,6 +5,9 @@ import java.util.PriorityQueue;
import ifaces.INumberGenerator;
/*
* @author Ieva Bekmane 3ITB
*/
public class Flight implements INumberGenerator{
private int flightNr;
private Date dateAndTime;
......@@ -60,7 +63,7 @@ public class Flight implements INumberGenerator{
this.airportTo = airportTo;
}
/*
* @brief Returns date of flight
* @brief Returns date and time of flight
*
* @param none
* @return dateAndTime
......@@ -68,21 +71,60 @@ public class Flight implements INumberGenerator{
public Date getDateAndTime() {
return dateAndTime;
}
/*
* @brief Allows to set date and time for flight
*
* @param dateAndTIme
* @return none
*/
public void setDateAndTime(Date dateAndTime) {
this.dateAndTime = dateAndTime;
}
/*
* @brief Returns duration of flight
*
* @param none
* @return duration
*/
public byte getDuration() {
return duration;
}
/*
* @brief Allows to set duration for flight
*
* @param duration
* @return none
*/
public void setDuration(byte duration) {
this.duration = duration;
}
/*
* @brief Returns passengers in flight
*
* @param none
* @return allPassengers
*/
public PriorityQueue<BoardingPass> getAllPassenger() {
return allPassenger;
}
/*
* @brief Allows to set passengers fot flight
*
* @param allPassengers
* @return none
*/
public void setAllPassenger(PriorityQueue<BoardingPass> allPassenger) {
this.allPassenger = allPassenger;
}
/*
* @brief Argument constructor
*
* @param dateAndTime
* @param duration
* @param airportFrom
* @param airportTo
* @return none
*/
public Flight(Date dateAndTime, byte duration, Airport airportFrom, Airport airportTo) {
setDateAndTime(dateAndTime);
setDuration(duration);
......@@ -90,12 +132,23 @@ public class Flight implements INumberGenerator{
setAirportTo(airportTo);
generateNr();
}
/*
* @brief Prints output
*
* @param none
* @return output
*/
@Override
public String toString() {
return "Flight [flightNr=" + flightNr + ", dateAndTime=" + dateAndTime + ", duration=" + duration
+ ", allPassenger=" + allPassenger + ", airportFrom=" + airportFrom + ", airportTo=" + airportTo + "]";
}
/*
* @brief Generates number for Flight
*
* @param none
* @return none
*/
@Override
public void generateNr() {
this.flightNr = flightNrCount;
......@@ -110,9 +163,10 @@ public class Flight implements INumberGenerator{
if(bp.getPassenger().equals(passenger))
return false;
}
BoardingPass newBP = new BoardingPass(passenger);
allPassenger.add(newBP);
return true;
}
return false;
}
......
......@@ -63,7 +63,7 @@ public class Passenger extends Person {
boolean isAdult, String extraNeeds) {
super(name, surname, idenNr, nationality, idenType);
setAudult(isAdult);
setExtraNeeds(getExtraNeeds());
generateExtraNeeds();
}
/*
......@@ -85,7 +85,7 @@ public class Passenger extends Person {
*/
@Override
public String toString() {
return "Passenger: " + getName() + " " + getSurname() + ", isAudult: " + isAdult + ", extraNeeds: " + extraNeeds;
return "Passenger: " + getName() + " " + getSurname() + ", isAudult: " + isAdult + ", extraNeeds: " + getExtraNeeds();
}
/*
* @brief Generates passengers extra needs
......
......@@ -12,6 +12,9 @@ import models.Flight;
import models.Passenger;
import models.VipPassenger;
/*
* @author Ieva Bekmane 3ITB
*/
public class AirportService {
public static ArrayList<Passenger> allPassenger = new ArrayList<Passenger>();
public static ArrayList<BoardingPass> allBoardingPasses = new ArrayList<BoardingPass>();
......@@ -101,10 +104,11 @@ public class AirportService {
if(f.equals(flight)) {
BoardingPass newPass = new BoardingPass(passenger);
allBoardingPasses.add(newPass);
return true;
}
}
return false;
}
return false;
}
/*
......
package test;
import org.junit.jupiter.api.Test;
import test.AirportTest;
public class TestAirport {
AirportTest test = new AirportTest();
@Test
public void testNegiativeParamters() {
test.testNegativeParameters();
}
}
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