Commit 7fbbc388 authored by Ieva's avatar Ieva
Browse files

new

parent 105b3cc6
No preview for this file type
No preview for this file type
......@@ -18,7 +18,7 @@ public class Main {
AirportService services = new AirportService();
//System.out.println(services.addNewPassenger("Ieva", "Bekmne", Nationality.ESTONIAN, IdenType.IDCARD, "1234", true, "No"));
System.out.println(services.addNewAirport(AirportName.BARSELONA, 100));
/**System.out.println(services.addNewAirport(AirportName.BARSELONA, 100));
System.out.println();
Passenger p = new Passenger("Name", "Surname", "1234", Nationality.ESTONIAN, IdenType.IDCARD, true, "NO");
......@@ -32,6 +32,54 @@ public class Main {
System.out.println(vip);
Airport a = new Airport(10000, AirportName.BARSELONA);
System.out.println(a);
System.out.println("----------------------------------------");
services.addNewPassenger("Liene", "Kalna", Nationality.ESTONIAN, IdenType.IDCARD, "AS12345", true, "NO");
for(Passenger pass : AirportService.allPassenger) {
System.out.println(pass);
}
System.out.println("-----------------------------------------");
services.deletePassengerByIdentNr("AS12345");
for(Passenger pass2 : AirportService.allPassenger) {
System.out.println(pass2);
}*/
//System.out.println(services.addNewPassenger("Ieva", "Zarina", Nationality.ESTONIAN, IdenType.PASSPORT, "AS12345", true, "No"));
//System.out.println(services.addNewPassenger("Zane", "Zarina", Nationality.ESTONIAN, IdenType.PASSPORT, "AS12345", true, "No"));
//System.out.println(services.addNewVipPassenger("Artis", "Liepins", Nationality.ITALIAN, IdenType.PASSPORT, "SA12345", true, "lol", "ZX1231"));
//System.out.println(services.addNewVipPassenger("Janis", "Kalnins", Nationality.ITALIAN, IdenType.PASSPORT, "DG23143", true, "lol", "ZX1231"));
/*System.out.println("-----------------------------------------");
for(Passenger pass2 : AirportService.allPassenger) {
System.out.println(pass2);
}
System.out.println("-----------------------------------------");
*/
/**System.out.println(services.addNewAirport(AirportName.OSLO, 2000));
for(Airport a : AirportService.allAirports) {
System.out.println(a);
}
System.out.println("-----------------------------------------");*/
/*System.out.println(services.deleteVipPassengerByVipNr(0));
System.out.println("-----------------------------------------");
for(Passenger pass2 : AirportService.allPassenger) {
System.out.println(pass2);
}
System.out.println("-----------------------------------------");*/
/*System.out.println(services.addNewAirport(AirportName.BARSELONA, 200));
System.out.println(services.addNewAirport(AirportName.RIGA, 300));
System.out.println(services.addNewAirport(AirportName.TALLINN, 500));
for(Airport a : AirportService.allAirports) {
System.out.println(a);
}
System.out.println(services.deleteAirportByAirportName(AirportName.OSLO));
for(Airport a : AirportService.allAirports) {
System.out.println(a);
}*/
}
}
......@@ -85,7 +85,7 @@ public class Passenger extends Person {
*/
@Override
public String toString() {
return "Passenger [isAudult=" + isAdult + ", extraNeeds=" + extraNeeds + "]";
return "Passenger: " + getName() + " " + getSurname() + " isAudult=" + isAdult + ", extraNeeds=" + extraNeeds + "]";
}
public void generateExtraNeeds() {
......
......@@ -137,11 +137,11 @@ public class Person {
* @return none
*/
public Person() {
this.name = " ";
this.surname = " ";
this.idenNr = " ";
this.nationality = null;
this.idenType = null;
this.name = "Name";
this.surname = "Surname";
this.idenNr = "AS12345";
this.nationality = Nationality.LATVIAN;
this.idenType = IdenType.IDCARD;
}
/*
* @brief Function helps print output
......
......@@ -16,6 +16,7 @@ public class AirportService {
public static ArrayList<Passenger> allPassenger = new ArrayList<Passenger>();
public static ArrayList<BoardingPass> allBoardingPasses = new ArrayList<BoardingPass>();
public static ArrayList<Airport> allAirports = new ArrayList<Airport>();
public static ArrayList<Flight> allFlights = new ArrayList<Flight>();
public AirportService() {
......@@ -27,7 +28,7 @@ public class AirportService {
return false;
else {
for(Passenger p : allPassenger) {
if(p.getIdenNr() == idenNr) {
if(p.getIdenNr().equals(idenNr)) {
return false;
}
}
......@@ -43,7 +44,7 @@ public class AirportService {
return false;
else {
for(Passenger p : allPassenger) {
if(p.getIdenNr() == idenNr) {
if(p.getIdenNr().equals(idenNr)) {
return false;
}
}
......@@ -66,7 +67,6 @@ public class AirportService {
}
return false;
}
}
public boolean addNewBoardingPassByObject(Flight flight, Passenger passenger) {
......@@ -80,16 +80,12 @@ public class AirportService {
}
public boolean addNewFlight(AirportName airportNameFrom, AirportName airportNameTo, Date date, byte duration) {
if(airportNameFrom == null || airportNameTo == null || date == null || duration == 0)
return false;
else {
}
return false;
}
public boolean deletePassengerByNameAndSurname(String name, String surname) {
if((name == null && surname == null) || allPassenger.isEmpty())
if(allPassenger.isEmpty())
return false;
else {
for(Passenger p : allPassenger) {
......@@ -97,9 +93,6 @@ public class AirportService {
allPassenger.remove(p);
return true;
}
else {
System.out.println("Can't delete passenger because it do not exist!");
}
}
return false;
}
......@@ -124,10 +117,15 @@ public class AirportService {
return false;
else {
for(Passenger p : allPassenger) {
if(p instanceof VipPassenger) {
if(((VipPassenger) p).getVipNr() == vipNr) {
allPassenger.remove(p);
return true;
}
}
}
return false;
}
return false;
}
public boolean deleteAirportByAirportNr(String airportNr) {
......@@ -145,7 +143,7 @@ public class AirportService {
}
public boolean deleteAirportByAirportName(AirportName airportName) {
if(airportName == null || allAirports.isEmpty()) {
if(allAirports.isEmpty()) {
return false;
}
else {
......@@ -157,7 +155,6 @@ public class AirportService {
}
return false;
}
}
public boolean deleteBoardingPassByBoardingPassNr(String boardingPassNr) {
......@@ -175,16 +172,17 @@ public class AirportService {
}
public boolean deleteFlightInAirportByNr(AirportName airportName, int flightNr) {
if(allAirports.isEmpty())
if(allFlights.isEmpty())
return false;
else {
for(Airport a : allAirports) {
if(a.getAirportName().equals(airportName)) {
for(Flight f : allFlights) {
if(f.getAirportFrom().equals(airportName) && f.getFlightNr() == flightNr) {
allFlights.remove(f);
return true;
}
}
return false;
}
return false;
}
public boolean addRegularPassengerInFlight(AirportName airportName, int flightNr, String extraNeeds) {
......
package test;
import org.junit.jupiter.api.Test;
import test.PersonTest;
public class PersonTest {
PersonTest test = new PersonTest();
@Test
public void testPerson() {
test.testPerson();
}
@Test
public void testSetName() {
}
}
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