-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathTransaction.cpp
80 lines (69 loc) · 1.83 KB
/
Transaction.cpp
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
78
79
80
#include "Transaction.h"
stack<Transaction> Transaction::transactionStore;
Transaction::Transaction()
{
}
Transaction::Transaction(const string &sender, const string &recipient, const double &amount, const string &type)
{
this->sender = sender;
this->recipient = recipient;
this->amount = amount;
this->type = type;
this->transactionDate = Transaction::get_current_time();
}
Transaction::Transaction(const string &sender, const string &recipient, const string &date, const string &type, const double &amount)
{
this->sender = sender;
this->recipient = recipient;
this->amount = amount;
this->type = type;
this->transactionDate = date;
}
void Transaction::addTransactionToStore(const Transaction &T)
{
transactionStore.push(T);
}
void Transaction::Transaction::setAmount(double amount)
{
this->amount = amount;
}
void Transaction::setType(string type)
{
this->type = type;
}
string Transaction::getType()
{
return this->type;
}
string Transaction::getSender()
{
return this->sender;
}
string Transaction::getRecipient()
{
return this->recipient;
}
double Transaction::getAmount()
{
return this->amount;
}
string Transaction::getTransactionDate()
{
return this->transactionDate;
}
stack<Transaction> Transaction::getTransactions()
{
stack<Transaction> st = transactionStore;
return st;
}
std::string Transaction::get_current_time()
{
auto now = std::chrono::system_clock::now();
std::time_t currentTime = std::chrono::system_clock::to_time_t(now);
std::tm *localTime = std::localtime(¤tTime);
std::stringstream ss;
ss << std::setw(2) << std::setfill('0') << localTime->tm_mday << "/"
<< std::setw(2) << std::setfill('0') << (localTime->tm_mon + 1) << "/"
<< std::setw(2) << std::setfill('0') << (localTime->tm_year + 1900);
return ss.str();
}