From 3779ae81792cc848f0a52ab0ad9309542b67a033 Mon Sep 17 00:00:00 2001 From: Imron Date: Mon, 14 Feb 2022 14:36:20 +0100 Subject: [PATCH] credit card payment --- .../exam/project/CreditCardTransaction.java | 10 +++ .../de/ci/exam/project/FlightReservation.java | 59 ++++++++++++++++++ .../hs/fulda/de/ci/exam/project/Payment.java | 37 +++++++++++ .../de/ci/exam/project/PaymentStatus.java | 5 ++ .../de/ci/exam/project/ReservationStatus.java | 5 ++ .../fulda/de/ci/exam/project/PaymentTest.java | 18 ++++++ .../fulda/de/ci/exam/project/Aircraft.class | Bin 1342 -> 1943 bytes .../hs/fulda/de/ci/exam/project/Flight.class | Bin 1575 -> 2375 bytes .../fulda/de/ci/exam/project/Itinerary.class | Bin 3662 -> 4399 bytes .../hs/fulda/de/ci/exam/project/Person.class | Bin 997 -> 2526 bytes .../fulda/de/ci/exam/project/PersonTest.class | Bin 2156 -> 2156 bytes 11 files changed, 134 insertions(+) create mode 100644 src/main/java/hs/fulda/de/ci/exam/project/CreditCardTransaction.java create mode 100644 src/main/java/hs/fulda/de/ci/exam/project/Payment.java create mode 100644 src/main/java/hs/fulda/de/ci/exam/project/PaymentStatus.java create mode 100644 src/main/java/hs/fulda/de/ci/exam/project/ReservationStatus.java create mode 100644 src/test/java/hs/fulda/de/ci/exam/project/PaymentTest.java 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 1491f290739c48cdef1a92013905085d3125d330..881faccca817170abf6c0c632369c62b0d7d3eb9 100644 GIT binary patch literal 1943 zcma)7U31e$6g_J@R^o^TOcFj?(f|Q}Bp_O7Y3ewXxP*iW@L&dp_Gx3UZ4p_@NHSA~ z>Hp}D=tDcxlo>kHAJ8Aw=~+o8s_n_}pw->$d(S=h>|Obvf8YNN;4U5&FpD(_QF8mY@9R*ZO7V?L9eMoX3aG1t}DZVPuTVGh>g8oV08vgTUu>p zwQNiMB>UE(@4Zs3(Ati$Yn#N$Z`iIKZVHsk5$_7G;dzWi3-m%1peEk~E5E@+HSMZF|`7C6_J2dd$@Eg8PB!yc_5l&-!v>*-?2 zZA+C;Ji8Od$-tIwdz)<^_hY-Sy#tk8+qmF1ht%`m7}()S?s?w9;84KabzS8*92o?P zEPhF|NHAiBccj~PRIm~!*2bx&JpW64_U2Gc2>&q^Kh!qmN+252ahi6hY6f^Qu8s9K ziJQRE$#J;M&)zIQcsYLgI9;?ddcdMLXDoVi^uVuKWY5E(y?{lo=jeHhEOUX+tM4GH zeG8ZviEgi6coewzC`e7^b*UL&;{ delta 547 zcmZvZNlwE+5Ji8t zQBc@)dJARhI<{FOd+(1_!#?`m*$$^EDL@yyh}lI6Q8^_{?NpOgkEboPg~78SyWH~A zH~1NaMuSxrfolc5#P~mGg-*_F2j%MQ&lDA!y4Wk&7`)^*#)ak{_L(amxAZS=>hg99 q+{>p+IPc>?BG}Jzb1ZS?4}#XU{4!!}R<0Os% 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 4005ae82e22a431d214270c85fa96fa5a18b23a2..7876b6beb186aa354847a166df6461ce280aea27 100644 GIT binary patch literal 2375 zcmb7G-E!MR6#mwKavT-6X_6A4!6^xe-K1(uX#vNfsY{5dTQ1y5r*Ol@QfxJfWTbV5 z4#P8W%R_JhGk7{vW_SP|is7tQPE=cX%!SVW`22k5obT-T?|)wZ1>hc<1_lh7?50v`ln)p(b4!Cd2 zb99*zU7O0VI?=z%i1N@omKY{RRtp>D@#2tLJ?Z}c7p*OOMBPkpl)s^#a??~mTJ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