Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions DriverCode/Driver_PaymentInterface.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
//Austin Ngyuyen
#ifndef DRIVER_PAYMENTTOTAL_H
#define DRIVER_PAYMENTTOTAL_H

#include <iostream>
#include "AvailableRooms.h"
#include "Reservation.h"
#include "Payment.h"
#include "PaymentTotal.h"
#include "Currency.h"
#include "Discount.h"

void test_PaymentTotal()
{
std::cout << "\n=== DRIVER: PaymentTotal Test ===\n";

std::cout << "Loading rooms...\n";

try {
AvailableRooms::LoadRoomsFILE("rooms.txt");
std::cout << "Rooms Loaded: "
<< AvailableRooms::getAllRoomLookups().size()
<< "\n";
}
catch (...) {
std::cout << "ERROR: Could not load rooms.txt\n";
return;
}


Reservation r;
r.makeReservation(
1001, // reservationID
5001, // guestID
2001, // roomID (must exist in rooms.txt)
20250910, // check-in
20250915, // check-out
2, // number of guests
20250901, // reservation date
"None", // special request
Discount(0.10f, "Holiday Discount")
);


Payment p;
p.setPaymentID(9001);
p.setReservation(r);
p.setPaymentMethod("Credit");
p.setCurrency(Currency("USD", 1.0f)); // USD = 1.0 exchange default rate
p.setPaymentDate(20250503);
p.setDiscount(Discount(0.10f, "Holiday Discount"));


PaymentTotal::processPayment(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";

std::cout << "\nCurrency: " << p.getCurrency().getCurrencyName() << "\n";
std::cout << "Discount: " << p.getDiscount().getDiscountName()
<< " (" << p.getDiscount().getDiscountRate() * 100 << "%)\n";

std::cout << "Final Total: $" << p.getTotalPrice() << "\n";
std::cout << "Status: " << p.getPaymentStatus() << "\n";
}

#endif
77 changes: 77 additions & 0 deletions PaymentInterface.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,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.9 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);
}
29 changes: 29 additions & 0 deletions PaymentInterface.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//Austin Nguyen
#ifndef PAYMENT_INTERFACE_H
#define PAYMENT_INTERFACE_H

#include <string>
#include <iostream>

#include "Payment.h"
#include "PaymentTotal.h"
#include "Reservation.h"
#include "Currency.h"
#include "Discount.h"


class PaymentInterface
{
public:

// Collects all fields needed to complete a payment
static Payment createPaymentFromUser(const Reservation& r);

// Prints a formatted receipt for user
static void displayPaymentSummary(const Payment& p);

// Full flow: create, calculate, process, display
static void runPaymentProcess(const Reservation& r);
};

#endif