Browse Source

credit card payment

feature-pr-payment
Imron 3 years ago
parent
commit
3779ae8179
  1. 10
      src/main/java/hs/fulda/de/ci/exam/project/CreditCardTransaction.java
  2. 59
      src/main/java/hs/fulda/de/ci/exam/project/FlightReservation.java
  3. 37
      src/main/java/hs/fulda/de/ci/exam/project/Payment.java
  4. 5
      src/main/java/hs/fulda/de/ci/exam/project/PaymentStatus.java
  5. 5
      src/main/java/hs/fulda/de/ci/exam/project/ReservationStatus.java
  6. 18
      src/test/java/hs/fulda/de/ci/exam/project/PaymentTest.java
  7. BIN
      target/classes/hs/fulda/de/ci/exam/project/Aircraft.class
  8. BIN
      target/classes/hs/fulda/de/ci/exam/project/Flight.class
  9. BIN
      target/classes/hs/fulda/de/ci/exam/project/Itinerary.class
  10. BIN
      target/classes/hs/fulda/de/ci/exam/project/Person.class
  11. BIN
      target/test-classes/hs/fulda/de/ci/exam/project/PersonTest.class

10
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;
}
}

59
src/main/java/hs/fulda/de/ci/exam/project/FlightReservation.java

@ -1,4 +1,63 @@
package hs.fulda.de.ci.exam.project; 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 { public class FlightReservation {
String reservationNumber;
FlightInstance flight;
HashMap<Passenger, FlightSeat> seatMap;
ReservationStatus status;
public FlightReservation(String reservationNumber, FlightInstance flight, HashMap<Passenger, FlightSeat> 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<Passenger, FlightSeat> getSeatMap() {
return seatMap;
}
public void setSeatMap(HashMap<Passenger, FlightSeat> 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;
}
} }

37
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;
}
}

5
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
}

5
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
}

18
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);
}
}

BIN
target/classes/hs/fulda/de/ci/exam/project/Aircraft.class

BIN
target/classes/hs/fulda/de/ci/exam/project/Flight.class

BIN
target/classes/hs/fulda/de/ci/exam/project/Itinerary.class

BIN
target/classes/hs/fulda/de/ci/exam/project/Person.class

BIN
target/test-classes/hs/fulda/de/ci/exam/project/PersonTest.class

Loading…
Cancel
Save