diff --git a/src/main/java/hs/fulda/de/ci/exam/project/CreditCardTransaction.java b/src/main/java/hs/fulda/de/ci/exam/project/CreditCardTransaction.java new file mode 100644 index 0000000..c2ac2da --- /dev/null +++ b/src/main/java/hs/fulda/de/ci/exam/project/CreditCardTransaction.java @@ -0,0 +1,10 @@ +package hs.fulda.de.ci.exam.project; + +public class CreditCardTransaction extends Payment { + String nameOnCard; + + public CreditCardTransaction(int id, String amount, PaymentStatus status, String nameOnCard) { + super(id, amount, status); + this.nameOnCard = nameOnCard; + } +} diff --git a/src/main/java/hs/fulda/de/ci/exam/project/FlightReservation.java b/src/main/java/hs/fulda/de/ci/exam/project/FlightReservation.java index f0e6c8e..f288009 100644 --- a/src/main/java/hs/fulda/de/ci/exam/project/FlightReservation.java +++ b/src/main/java/hs/fulda/de/ci/exam/project/FlightReservation.java @@ -1,4 +1,63 @@ package hs.fulda.de.ci.exam.project; +import java.util.HashMap; + +import static hs.fulda.de.ci.exam.project.PaymentStatus.Completed; +import static hs.fulda.de.ci.exam.project.ReservationStatus.Confirmed; + public class FlightReservation { + String reservationNumber; + FlightInstance flight; + HashMap seatMap; + ReservationStatus status; + + public FlightReservation(String reservationNumber, FlightInstance flight, HashMap seatMap, ReservationStatus status) { + this.reservationNumber = reservationNumber; + this.flight = flight; + this.seatMap = seatMap; + this.status = status; + } + + public FlightReservation(){ + + } + + + public String getReservationNumber() { + return reservationNumber; + } + + public void setReservationNumber(String reservationNumber) { + this.reservationNumber = reservationNumber; + } + + public FlightInstance getFlight() { + return flight; + } + + public void setFlight(FlightInstance flight) { + this.flight = flight; + } + + public HashMap getSeatMap() { + return seatMap; + } + + public void setSeatMap(HashMap seatMap) { + this.seatMap = seatMap; + } + + public ReservationStatus getStatus() { + return status; + } + + public void setStatus(ReservationStatus status) { + this.status = status; + } + + public void makePayment(Payment credit_card_payment) { + System.out.println("processing payment"); + credit_card_payment.status = Completed; + status = Confirmed; + } } diff --git a/src/main/java/hs/fulda/de/ci/exam/project/Payment.java b/src/main/java/hs/fulda/de/ci/exam/project/Payment.java new file mode 100644 index 0000000..f5bc310 --- /dev/null +++ b/src/main/java/hs/fulda/de/ci/exam/project/Payment.java @@ -0,0 +1,37 @@ +package hs.fulda.de.ci.exam.project; + +public class Payment { + int id; + String amount; + PaymentStatus status; + + public Payment(int id, String amount, PaymentStatus status) { + this.id = id; + this.amount = amount; + this.status = status; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getAmount() { + return amount; + } + + public void setAmount(String amount) { + this.amount = amount; + } + + public PaymentStatus isStatus() { + return status; + } + + public void setStatus(PaymentStatus status) { + this.status = status; + } +} diff --git a/src/main/java/hs/fulda/de/ci/exam/project/PaymentStatus.java b/src/main/java/hs/fulda/de/ci/exam/project/PaymentStatus.java new file mode 100644 index 0000000..cad1ac7 --- /dev/null +++ b/src/main/java/hs/fulda/de/ci/exam/project/PaymentStatus.java @@ -0,0 +1,5 @@ +package hs.fulda.de.ci.exam.project; + +public enum PaymentStatus { + Unpaid, Pending, Completed, Failed, Declined, Cancelled, Abandoned, Settling, Settled, Refunded +} diff --git a/src/main/java/hs/fulda/de/ci/exam/project/ReservationStatus.java b/src/main/java/hs/fulda/de/ci/exam/project/ReservationStatus.java new file mode 100644 index 0000000..ed4005a --- /dev/null +++ b/src/main/java/hs/fulda/de/ci/exam/project/ReservationStatus.java @@ -0,0 +1,5 @@ +package hs.fulda.de.ci.exam.project; + +public enum ReservationStatus { + Requested, Pending, Confirmed, CheckedIn, Cancelled, Abandoned +} diff --git a/src/test/java/hs/fulda/de/ci/exam/project/PaymentTest.java b/src/test/java/hs/fulda/de/ci/exam/project/PaymentTest.java new file mode 100644 index 0000000..d969b5e --- /dev/null +++ b/src/test/java/hs/fulda/de/ci/exam/project/PaymentTest.java @@ -0,0 +1,18 @@ +package hs.fulda.de.ci.exam.project; + +import org.junit.Test; + +import static hs.fulda.de.ci.exam.project.PaymentStatus.*; +import static hs.fulda.de.ci.exam.project.ReservationStatus.Confirmed; +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class PaymentTest { + @Test + public void should_be_possible_to_pay_with_credit_card(){ + Payment credit_card_payment = new CreditCardTransaction(11, "139€", Unpaid, "Imron Gamidli"); + FlightReservation reservation = new FlightReservation(); + reservation.makePayment(credit_card_payment); + assertEquals(Confirmed, reservation.getStatus()); + assertEquals(Completed, credit_card_payment.status); + } +} diff --git a/target/classes/hs/fulda/de/ci/exam/project/Aircraft.class b/target/classes/hs/fulda/de/ci/exam/project/Aircraft.class index 1491f29..881facc 100644 Binary files a/target/classes/hs/fulda/de/ci/exam/project/Aircraft.class and b/target/classes/hs/fulda/de/ci/exam/project/Aircraft.class differ diff --git a/target/classes/hs/fulda/de/ci/exam/project/Flight.class b/target/classes/hs/fulda/de/ci/exam/project/Flight.class index 4005ae8..7876b6b 100644 Binary files a/target/classes/hs/fulda/de/ci/exam/project/Flight.class and b/target/classes/hs/fulda/de/ci/exam/project/Flight.class differ diff --git a/target/classes/hs/fulda/de/ci/exam/project/Itinerary.class b/target/classes/hs/fulda/de/ci/exam/project/Itinerary.class index b7c1f85..ee3c42e 100644 Binary files a/target/classes/hs/fulda/de/ci/exam/project/Itinerary.class and b/target/classes/hs/fulda/de/ci/exam/project/Itinerary.class differ diff --git a/target/classes/hs/fulda/de/ci/exam/project/Person.class b/target/classes/hs/fulda/de/ci/exam/project/Person.class index 79140f2..f688df2 100644 Binary files a/target/classes/hs/fulda/de/ci/exam/project/Person.class and b/target/classes/hs/fulda/de/ci/exam/project/Person.class differ diff --git a/target/test-classes/hs/fulda/de/ci/exam/project/PersonTest.class b/target/test-classes/hs/fulda/de/ci/exam/project/PersonTest.class index 3f5b4f6..5975c89 100644 Binary files a/target/test-classes/hs/fulda/de/ci/exam/project/PersonTest.class and b/target/test-classes/hs/fulda/de/ci/exam/project/PersonTest.class differ