diff --git a/src/main/java/hs/fulda/de/ci/exam/project/Address.java b/src/main/java/hs/fulda/de/ci/exam/project/Address.java index 86898aa..2fd7b89 100644 --- a/src/main/java/hs/fulda/de/ci/exam/project/Address.java +++ b/src/main/java/hs/fulda/de/ci/exam/project/Address.java @@ -1,6 +1,28 @@ package hs.fulda.de.ci.exam.project; public class Address { + String streetAddress; + String city; + String state; + String zipCode; + String country; + public Address(String streetAddress, String city, String state, String zipCode, String country) { + this.streetAddress = streetAddress; + this.city = city; + this.state = state; + this.zipCode = zipCode; + this.country = country; + } + + @Override + public String toString() { + return "Address{" + + "streetAddress='" + streetAddress + '\'' + + ", city='" + city + '\'' + + ", state='" + state + '\'' + + ", zipCode='" + zipCode + '\'' + + ", country='" + country + '\'' + + '}'; } } diff --git a/src/main/java/hs/fulda/de/ci/exam/project/Airport.java b/src/main/java/hs/fulda/de/ci/exam/project/Airport.java index 673fcaa..8f1ee49 100644 --- a/src/main/java/hs/fulda/de/ci/exam/project/Airport.java +++ b/src/main/java/hs/fulda/de/ci/exam/project/Airport.java @@ -4,10 +4,16 @@ import java.util.LinkedList; public class Airport { + protected String name; public Address address; - public LinkedList flights; protected String code; - protected String name; + public LinkedList flights = new LinkedList<>(); + + public Airport(String name, Address address, String code) { + this.name = name; + this.address = address; + this.code = code; + } public String getName() { return this.name; @@ -24,4 +30,9 @@ public class Airport { public LinkedList getFlights() { return this.flights; } + + @Override + public String toString() { + return "Airport{" + "name='" + name + '\'' + ", address=" + address + ", code='" + code + '\'' + '}'; + } } diff --git a/src/main/java/hs/fulda/de/ci/exam/project/ExampleClass.java b/src/main/java/hs/fulda/de/ci/exam/project/ExampleClass.java deleted file mode 100644 index 10e23b9..0000000 --- a/src/main/java/hs/fulda/de/ci/exam/project/ExampleClass.java +++ /dev/null @@ -1,13 +0,0 @@ -package hs.fulda.de.ci.exam.project; - -import java.util.LinkedList; - -public class ExampleClass { - public static void main(String[] args) { - LinkedList list = new LinkedList<>(); - list.add("heello"); - list.add("world"); - list.remove("heello"); - System.out.println(list); - } -} diff --git a/src/main/java/hs/fulda/de/ci/exam/project/Flight.java b/src/main/java/hs/fulda/de/ci/exam/project/Flight.java index fc75e78..0af18a1 100644 --- a/src/main/java/hs/fulda/de/ci/exam/project/Flight.java +++ b/src/main/java/hs/fulda/de/ci/exam/project/Flight.java @@ -1,4 +1,47 @@ package hs.fulda.de.ci.exam.project; +import java.util.LinkedList; + public class Flight { + String flightNumber; + Airport departure; + Airport arrival; + int durationInMinutes; + LinkedList flightInstances; + + public Flight(String flightNumber, Airport departure, Airport arrival, int durationInMinutes) { + this.flightNumber = flightNumber; + this.departure = departure; + this.arrival = arrival; + this.durationInMinutes = durationInMinutes; + } + + public LinkedList getInstances() { + return this.flightInstances; + } + + public boolean cancel() { + return true; + } + + public boolean addFlightSchedule() { + return true; + } + + public String getFlightNumber() { + return flightNumber; + } + + public Airport getDeparture() { + return departure; + } + + public Airport getArrival() { + return arrival; + } + + public int getDurationInMinutes() { + return durationInMinutes; + } + } diff --git a/src/main/java/hs/fulda/de/ci/exam/project/FlightInstance.java b/src/main/java/hs/fulda/de/ci/exam/project/FlightInstance.java new file mode 100644 index 0000000..50672a7 --- /dev/null +++ b/src/main/java/hs/fulda/de/ci/exam/project/FlightInstance.java @@ -0,0 +1,4 @@ +package hs.fulda.de.ci.exam.project; + +public class FlightInstance { +} diff --git a/src/test/java/hs/fulda/de/ci/exam/project/AirportClassTest.java b/src/test/java/hs/fulda/de/ci/exam/project/AirportClassTest.java deleted file mode 100644 index f4b2f05..0000000 --- a/src/test/java/hs/fulda/de/ci/exam/project/AirportClassTest.java +++ /dev/null @@ -1,52 +0,0 @@ -package hs.fulda.de.ci.exam.project; - -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.Mock; -import org.mockito.junit.jupiter.MockitoExtension; - -import java.util.LinkedList; - -import static org.assertj.core.api.Assertions.*; - -@ExtendWith(MockitoExtension.class) -public class AirportClassTest { - - - @Test - void test_getName(){ - Airport airport = new Airport(); - airport.name = "fraport"; - assertThat(airport.getName()).describedAs("get airport name").isEqualTo("fraport"); - } - - @Test - void test_getCode(){ - Airport airport = new Airport(); - airport.code = "PC994"; - assertThat(airport.getCode()).describedAs("get airport code").isEqualTo("PC994"); - } - - @Test - void test_getAddress(){ - Airport airport = new Airport(); - Address address = new Address("Mittelstr", "Fulda", "Hessen", "36037", "Germany"); - airport.address = address; - assertThat(airport.getAddress()).describedAs("get address of airport").isEqualTo(address); - } - - @Test - void test_getFlights(){ - Airport airport = new Airport(); - LinkedList flights = new LinkedList<>(); - Flight flight1 = new Flight(); - flights.add(flight1); - airport.flights = flights; - assertThat(airport.getFlights()).describedAs("get all flights of the airport").isEqualTo(flights); - } - - - - - -} diff --git a/src/test/java/hs/fulda/de/ci/exam/project/AirportTest.java b/src/test/java/hs/fulda/de/ci/exam/project/AirportTest.java new file mode 100644 index 0000000..3ac3bf4 --- /dev/null +++ b/src/test/java/hs/fulda/de/ci/exam/project/AirportTest.java @@ -0,0 +1,49 @@ +package hs.fulda.de.ci.exam.project; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +import java.util.LinkedList; + +import static org.assertj.core.api.Assertions.*; + +@ExtendWith(MockitoExtension.class) +public class AirportTest { + + Address address_fr = new Address("Frankfurt str", "Frankfurt", "Hessen", "63023", "Germany"); + Airport airport_fr = new Airport("Fraport", address_fr, "1234"); + + + Address address1_ist = new Address("Istanbul str", "Istanbul", "Fatih", "9019", "Turkey"); + Airport airport1_ist = new Airport("Istanbul", address1_ist, "5678"); + + Flight flight1 = new Flight("1", airport_fr, airport1_ist, 140); + Flight flight2 = new Flight("2", airport1_ist, airport_fr, 120); + + + @Test + void test_getName() { + assertThat(airport_fr.getName()).describedAs("get airport name").isEqualTo("Fraport"); + } + + @Test + void test_getCode() { + assertThat(airport_fr.getCode()).describedAs("get airport code").isEqualTo("1234"); + } + + @Test + void test_getAddress() { + assertThat(airport_fr.getAddress()).describedAs("get address of airport").isEqualTo(address_fr); + } + + @Test + void test_getFlights() { + LinkedList flist = new LinkedList<>(); + flist.add(flight1); + + airport_fr.flights.add(flight1); + + assertThat(airport_fr.getFlights()).describedAs("get all flights of the airport").isEqualTo(flist); + } +} diff --git a/src/test/java/hs/fulda/de/ci/exam/project/ExampleClassTest.java b/src/test/java/hs/fulda/de/ci/exam/project/ExampleClassTest.java deleted file mode 100644 index a90cba9..0000000 --- a/src/test/java/hs/fulda/de/ci/exam/project/ExampleClassTest.java +++ /dev/null @@ -1,11 +0,0 @@ -package hs.fulda.de.ci.exam.project; - -import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.*; - -public class ExampleClassTest { - @Test - void testExampleClass() { - assertTrue(true); - } -} diff --git a/src/test/java/hs/fulda/de/ci/exam/project/FlightTest.java b/src/test/java/hs/fulda/de/ci/exam/project/FlightTest.java new file mode 100644 index 0000000..b402045 --- /dev/null +++ b/src/test/java/hs/fulda/de/ci/exam/project/FlightTest.java @@ -0,0 +1,36 @@ +package hs.fulda.de.ci.exam.project; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +class FlightTest { + + @Test + void getInstances() { + } + + @Test + void cancel() { + } + + @Test + void addFlightSchedule() { + } + + @Test + void getFlightNumber() { + } + + @Test + void getDeparture() { + } + + @Test + void getArrival() { + } + + @Test + void getDurationInMinutes() { + } +} \ No newline at end of file diff --git a/target/classes/hs/fulda/de/ci/exam/project/ExampleClass.class b/target/classes/hs/fulda/de/ci/exam/project/ExampleClass.class deleted file mode 100644 index ecca178..0000000 Binary files a/target/classes/hs/fulda/de/ci/exam/project/ExampleClass.class and /dev/null differ diff --git a/target/test-classes/hs/fulda/de/ci/exam/project/ExampleClassTest.class b/target/test-classes/hs/fulda/de/ci/exam/project/ExampleClassTest.class deleted file mode 100644 index 5a0536d..0000000 Binary files a/target/test-classes/hs/fulda/de/ci/exam/project/ExampleClassTest.class and /dev/null differ