-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTransaction.cpp
72 lines (67 loc) · 1.48 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
#define _CRT_SECURE_NO_WARNINGS
#include "Transaction.h"
#include "Account.h"
#include <string.h>
#include <iostream>
using namespace std;
//C'tor
Transaction::Transaction(Account* s, Account* d, double amount, const char* date) : m_date(NULL)
{
SetAmount(amount);
SetDate(date);
SetSource(s);
SetDes(d);
}
//Copy C'tor
Transaction::Transaction(const Transaction& other) : m_date(NULL)
{
SetAmount(other.GetAmount());
SetDate(other.GetDate());
SetSource(other.GetSource());
SetDes(other.GetDes());
}
//Set account source
void Transaction::SetSource(Account* src)
{
m_source = src;
}
//Set account destination
void Transaction::SetDes(Account* dst)
{
m_destination = dst;
}
//Set the amount of the transaction
void Transaction::SetAmount(double amount)
{
m_amount = amount;
}
//Set the date of the transaction
void Transaction::SetDate(const char* date)
{
if (this->m_date != nullptr)
{
delete m_date;
}
m_date = new char[strlen(date) + 1];
strcpy(m_date, date);
}
//Returns the account from which the transaction was made ( OUT )
Account* Transaction::GetSource() const
{
return m_source;
}
//Returns the account to which the transaction was made ( IN )
Account* Transaction::GetDes() const
{
return m_destination;
}
//Retuen the amount of the transaction
double Transaction::GetAmount() const
{
return m_amount;
}
//Return the date of the transaction
char* Transaction::GetDate() const
{
return m_date;
}