-
Notifications
You must be signed in to change notification settings - Fork 5
/
Account.cpp
101 lines (82 loc) · 2.78 KB
/
Account.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#include "Account.h" // class implemented
using namespace std;
// File scope starts here
/////////////////////////////// PUBLIC ///////////////////////////////////////
//============================= LIFECYCLE ====================================
// Account Default + Overloaded Constructor
Account::Account(int aAccountID, float aValue) : mAccountID(aAccountID), mValue(aValue) {
this->SetAccount(aAccountID, aValue);
}
// end Account constructor
//============================= OPERATIONS ===================================
// function that deposits amount.
void Account::Deposit(float aAmount) {
if (aAmount < 0.0)
cout << "ERROR: Deposit amount cannot be nagative." << endl;
else {
this->mValue += aAmount;
cout << aAmount << " has been deposited to account #: " << this->GetAccountID() << endl;
}
}
// end function Deposit
// function that withdraws amount.
void Account::Withdraw(float aAmount) {
if (aAmount < 0.0)
cout << "ERROR: Withdrawn amount cannot be nagative." << endl;
else if(aAmount > this->GetValue()){
cout << "ERROR: Withdrawn amount exceeds available balance." << endl;
}
else {
this->mValue -= aAmount;
cout << aAmount << " has been withdrawl from account #: " << this->GetAccountID() << endl;
}
}
// end function Withdraw
// function that withdraws amount.
void Account::PrintBalance()const {
cout << this->GetAccountID() << " has total balance of Rs. " << this->GetValue() << " /-." << endl;
}
// end function PrintBalance
//============================= ACESS ===================================
// function that sets ID of Account
void Account::SetAccountID(int aAccountID) {
if (aAccountID < 0.0)
cout << "ERROR: Account ID cannot be nagative." << endl;
else
this->mAccountID = aAccountID;
}
// end function SetAccountID
// function that sets value of Account
void Account::SetValue(float aValue) {
if (aValue < 0.0)
cout << "ERROR: Account value cannot be nagative." << endl;
else
this->mValue = aValue;
}
// end function SetValue
// function that sets Account
void Account::SetAccount(int aAccountID, float aValue) {
this->SetAccountID(aAccountID);
this->SetValue(aValue);
}
// end function SetAccount
// Overloaded function that sets the Account
void Account::SetAccount(const Account& obj) {
this->SetAccount(obj.GetAccountID(), obj.GetValue());
}
// end function SetAccount
// function that gets ID of Account
int Account::GetAccountID()const {
return this->mAccountID;
}
// end function GetAccountID
// function that gets value of Account
float Account::GetValue()const {
return this->mValue;
}
// end function GetValue
// function that gets the Account
const Account& Account::GetAccount()const {
return *this;
}
// end function GetAccount