You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
84 lines
2.3 KiB
84 lines
2.3 KiB
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.PaymentStatus.Failed;
|
|
import static hs.fulda.de.ci.exam.project.ReservationStatus.Cancelled;
|
|
import static hs.fulda.de.ci.exam.project.ReservationStatus.Confirmed;
|
|
|
|
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 payment) {
|
|
System.out.println("processing payment");
|
|
if (payment.isValid()) {
|
|
payment.status = Completed;
|
|
setStatus(Confirmed);
|
|
} else {
|
|
payment.status = Failed;
|
|
setStatus(Cancelled);
|
|
}
|
|
|
|
|
|
}
|
|
|
|
public boolean notifyUser(String type, String to, String content) {
|
|
Notification notification = null;
|
|
switch (type) {
|
|
case "email":
|
|
notification = new EmailNotification(to, content);
|
|
break;
|
|
case "sms":
|
|
notification = new SmsNotification(to, content);
|
|
break;
|
|
}
|
|
return notification.sendNotification();
|
|
}
|
|
}
|