From 544cedf28de3280cd0521af7b22b3ec3e6ee90f3 Mon Sep 17 00:00:00 2001 From: Imron Date: Mon, 24 Jan 2022 15:37:35 +0100 Subject: [PATCH] refactor Airport --- .../hs/fulda/de/ci/exam/project/Address.java | 22 ++++++++ .../hs/fulda/de/ci/exam/project/Airport.java | 15 ++++- .../de/ci/exam/project/ExampleClass.java | 13 ----- .../hs/fulda/de/ci/exam/project/Flight.java | 43 +++++++++++++++ .../de/ci/exam/project/FlightInstance.java | 4 ++ .../de/ci/exam/project/AirportClassTest.java | 52 ------------------ .../fulda/de/ci/exam/project/AirportTest.java | 49 +++++++++++++++++ .../de/ci/exam/project/ExampleClassTest.java | 11 ---- .../fulda/de/ci/exam/project/FlightTest.java | 36 ++++++++++++ .../de/ci/exam/project/ExampleClass.class | Bin 865 -> 0 bytes .../de/ci/exam/project/ExampleClassTest.class | Bin 552 -> 0 bytes 11 files changed, 167 insertions(+), 78 deletions(-) delete mode 100644 src/main/java/hs/fulda/de/ci/exam/project/ExampleClass.java create mode 100644 src/main/java/hs/fulda/de/ci/exam/project/FlightInstance.java delete mode 100644 src/test/java/hs/fulda/de/ci/exam/project/AirportClassTest.java create mode 100644 src/test/java/hs/fulda/de/ci/exam/project/AirportTest.java delete mode 100644 src/test/java/hs/fulda/de/ci/exam/project/ExampleClassTest.java create mode 100644 src/test/java/hs/fulda/de/ci/exam/project/FlightTest.java delete mode 100644 target/classes/hs/fulda/de/ci/exam/project/ExampleClass.class delete mode 100644 target/test-classes/hs/fulda/de/ci/exam/project/ExampleClassTest.class 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 ecca17874d37e9ea9a7ebaedce8b30d0ae59482e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 865 zcma)4%Wl&^6g`udlVC`jGyw_$`U1y+4zOX7s+$T{79a(s0#=iFNT!VA$d5u-d=o5M z2_!y%k3!sui%200Y{~cDGjq;8bH_h^e*F&M2_9E*32h6vs>q>T#%&Ytl(AvrW(8Z= zu3`swE!?x(^oWT<&+DxaspP)4uBP!m%3!jaGe5h+ujgN0Z!HX<2>$K-#3**}RB84xo}iQmkKD&#L|_z7Ks z6ak&SF>iGdX0T>vlct+n+Hrslm_N@vIWRLJ`d*=mQ)Cp2?itwU`ErfEr3}Oh<@R~L ziaJ#lG_Xd9A%7yV9L1e)$h|&8-s{#2rzjqF>!mDEWgUJ&xqFI=5zoVjuai7rp-gX$ p1Y6{-P42d-m1)?@MA4)Sw5N@$xJE6nQ)SF#$U0>VHweq&<}Y*3#m)c# 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 5a0536dbf29808bdfa847f04615bae352c9a56a4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 552 zcmb7Bu};G<6g;y%3+|;zL(j>AS#BVWy82A7_ z3h@j@RDuN$_jK?1&iCZE_m@`y$7lucuoj?!bsrl(nhe!bl`4D2P;T!>3|=oAN`}=? zrSh_v4y5jjK|-BIn8hNAgjSBvnw}ji!_W!GhTj#*Q1GGTvEuSUOnI)eiHt2jCz2CCrtTnu}cVnOks^ z6*`s|%H?d%+qw&#iMSUvR8aM?S;H2#84mxGm*P4Lo``hBuLf=>hTXptb&ZjFmO7w) ziS%_rvAp)}euO=g=>yy;fw@S8J~2*}QLP+2fjxeX7YNjDBS5p%psCQf|x eE%u&K`Vj{-21z}V{5DvonX_M^O5aUbLj41o(SAh$