Commit 7910c336 authored by Ieva's avatar Ieva
Browse files

Airport class updated

parent db883406
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="src"/>
<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
......@@ -5,6 +5,8 @@ import java.util.ArrayList;
import enums.AirportName;
import enums.IdenType;
import enums.Nationality;
import models.Airport;
import models.BoardingPass;
import models.Passenger;
import services.AirportService;
......@@ -17,6 +19,14 @@ public class Main {
//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();
Passenger p = new Passenger("Name", "Surname", "1234", Nationality.ESTONIAN, IdenType.IDCARD, true, "NO");
BoardingPass b = new BoardingPass(p);
System.out.println(b);
Airport a = new Airport(10000, AirportName.BARSELONA);
System.out.println(a);
}
}
package models;
import java.util.Random;
import enums.AirportName;
import ifaces.INumberGenerator;
......@@ -26,10 +28,21 @@ public class Airport implements INumberGenerator{
public Airport(int capacity, AirportName airportName) {
setCapacity(capacity);
setAirportName(airportName);
generateNr();
}
@Override
public void generateNr() {
Random rand = new Random();
StringBuilder s = new StringBuilder();
for(int i = 0; i < 3; i++) {
s.append(airportName.toString().charAt(i));
}
s.append(rand.nextInt(100 - 10) + 10);
this.airportNr = s.toString();
}
@Override
public String toString() {
return "Airport [airportNr=" + airportNr + ", capacity=" + capacity + ", airportName=" + airportName + "]";
}
......
......@@ -24,8 +24,8 @@ public class BoardingPass implements INumberGenerator{
return boardingPassNr;
}
public BoardingPass(Passenger passenger) {
super();
this.passenger = passenger;
generateNr();
}
public void generateGroupByPriority() {
......@@ -42,4 +42,10 @@ public class BoardingPass implements INumberGenerator{
sb.append(group);
this.boardingPassNr = sb.toString();
}
@Override
public String toString() {
return "BoardingPass [boardingPassNr=" + boardingPassNr + ", group=" + group + ", passenger=" + passenger
+ ", seat=" + seat + "]";
}
}
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() {
}
}
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