#include "paymentprocessor.h" /*PaymentProcessor::PaymentProcessor(QObject *parent) : QObject(parent), zubereitung(Tonkotsu, Soy), totalAmount(0), paidAmount(0) // Initialisierung von zubereitung mit Standardwerten { }*/ PaymentProcessor::PaymentProcessor(Zubereitung* zubereitung, QObject *parent) : QObject(parent), zubereitung(zubereitung), totalAmount(0), paidAmount(0) { } PaymentProcessor::~PaymentProcessor() { delete zubereitung; // Speicher freigeben } //PaymentProcessor::PaymentProcessor(const Zubereitung &zubereitung, QObject *parent) // : QObject(parent), totalAmount(0.0), paidAmount(0.0) {} /*const Zubereitung& PaymentProcessor::getZubereitung() const { return zubereitung; } */ double PaymentProcessor::getTotalAmount() const { return totalAmount; } double PaymentProcessor::getPaidAmount() const { return paidAmount; } void PaymentProcessor::processCardPayment() { // Beispielhafte Logik für Kartenzahlung paidAmount = totalAmount; emit paymentUpdated(paidAmount); emit paymentSuccessful(); } void PaymentProcessor::processCashPayment(double amount) { paidAmount += amount; emit paymentUpdated(paidAmount); if (paidAmount >= totalAmount) { cashBalance += paidAmount; emit paymentSuccessful(); double change = paidAmount - totalAmount; emit calculateChange(paidAmount, totalAmount); } } void PaymentProcessor::reset() { totalAmount = 0; paidAmount = 0; emit paymentUpdated(paidAmount); } void PaymentProcessor::setTotalAmount(double amount) { totalAmount = amount; } double PaymentProcessor::getCashBalance() const { return cashBalance; } void PaymentProcessor::clearCashBalance() { cashBalance = 0.0; } double PaymentProcessor::getChange() const { return paidAmount - totalAmount; }