-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Expand file tree
/
Copy pathTransaction.cpp
More file actions
36 lines (32 loc) · 1.61 KB
/
Transaction.cpp
File metadata and controls
36 lines (32 loc) · 1.61 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
#include "Transaction.hpp"
#include <iostream>
#include <iomanip>
Transaction::Transaction(std::string transactionId, std::string walletId,
TransactionType type, double amount, std::string timestamp,
std::string description)
: transactionId(transactionId), walletId(walletId), type(type),
amount(amount), timestamp(timestamp), description(description), status(false) {}
std::string Transaction::getTransactionId() const { return transactionId; }
std::string Transaction::getWalletId() const { return walletId; }
TransactionType Transaction::getType() const { return type; }
double Transaction::getAmount() const { return amount; }
std::string Transaction::getTimestamp() const { return timestamp; }
std::string Transaction::getDescription() const { return description; }
bool Transaction::getStatus() const { return status; }
void Transaction::setStatus(bool status) {
this->status = status;
}
void Transaction::displayInfo() const {
std::cout << "Transaction ID: " << transactionId << std::endl;
std::cout << "Type: ";
switch (type) {
case TransactionType::ADD_MONEY: std::cout << "Add Money"; break;
case TransactionType::WITHDRAW: std::cout << "Withdraw"; break;
case TransactionType::TRANSFER: std::cout << "Transfer"; break;
}
std::cout << std::endl;
std::cout << "Amount: $" << std::fixed << std::setprecision(2) << amount << std::endl;
std::cout << "Time: " << timestamp << std::endl;
std::cout << "Description: " << description << std::endl;
std::cout << "Status: " << (status ? "Success" : "Pending") << std::endl;
}