Repository navigation
Expand file tree
/
Copy pathPaymentInterface.cpp
More file actions
77 lines (57 loc) · 2.17 KB
/
Copy pathPaymentInterface.cpp
File metadata and controls
77 lines (57 loc) · 2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
//Austin
#include "PaymentInterface.h"
#include <iomanip>
Payment PaymentInterface::createPaymentFromUser(const Reservation& r)
{
Payment p;
p.setReservation(r);
p.setGuestID(r.getGuestID());
p.setRoomID(r.getRoomID());
p.setCheckInDate(r.getCheckInDate());
p.setCheckOutDate(r.getCheckOutDate());
p.setDiscount(r.getSpecialDiscount());
// Ask user for Payment Method
std::string method;
std::cout << "Enter payment method (Credit/Debit/Cash): ";
std::getline(std::cin, method);
p.setPaymentMethod(method);
// Ask user for Currency
std::string curName;
float curRate;
std::cout << "Enter currency code (USD/EUR/JPY): ";
std::getline(std::cin, curName);
std::cout << "Enter currency rate (ex: 1.0 for USD, 0.92 for EUR, 150 for JPY): ";
std::cin >> curRate;
std::cin.ignore();
p.setCurrency(Currency(curName, curRate));
// Ask for Payment Date (YYYYMMDD)
int date;
std::cout << "Enter payment date (YYYYMMDD): ";
std::cin >> date;
std::cin.ignore();
p.setPaymentDate(date);
return p;
}
void PaymentInterface::displayPaymentSummary(const Payment& p)
{
std::cout << "\n===== PAYMENT SUMMARY =====\n";
std::cout << "Guest ID: " << p.getGuestID() << "\n";
std::cout << "Room ID: " << p.getRoomID() << "\n";
std::cout << "Check-In: " << p.getCheckInDate() << "\n";
std::cout << "Check-Out: " << p.getCheckOutDate() << "\n\n";
std::cout << "Currency: " << p.getCurrency().getCurrencyName() << "\n";
std::cout << "Discount: " << p.getDiscount().getDiscountName()
<< " (" << p.getDiscount().getDiscountRate() * 100 << "%)\n";
std::cout << "Final Total: $" << std::fixed << std::setprecision(2)
<< p.getTotalPrice() << "\n";
std::cout << "Payment Status: " << p.getPaymentStatus() << "\n";
}
void PaymentInterface::runPaymentProcess(const Reservation& r)
{
std::cout << "\n=== PROCESSING PAYMENT ===\n";
Payment p = createPaymentFromUser(r);
// Process payment using control class
PaymentTotal::processPayment(p);
// Display results to the user
displayPaymentSummary(p);
}