-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclsTransferScreen.h
More file actions
95 lines (75 loc) · 2.64 KB
/
Copy pathclsTransferScreen.h
File metadata and controls
95 lines (75 loc) · 2.64 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
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
#pragma once
#include <iostream>
#include "clsScreen.h"
#include "clsPerson.h"
#include "clsBankClient.h"
#include "clsInputValidate.h"
#include "clsColor.h"
using namespace std;
class clsTransferScreen : protected clsScreen
{
private :
static void _PrintClient(clsBankClient Client)
{
cout << clsColor::Blink() + clsColor::Text(93) + "\nClient Card : " + clsColor::Reset();
cout << clsColor::Text(226) + "\n_______________________________\n";
cout << clsColor::Text(196) + "\nFull Name : " + clsColor::Text(51) << Client.FullName();
cout << clsColor::Text(196) + "\nAccount Number : " + clsColor::Text(51) << Client.AccountNumber();
cout << clsColor::Text(196) + "\nBalance : " + clsColor::Text(51) << Client.AccountBalance;
cout << clsColor::Text(226) + "\n_______________________________\n" + clsColor::Reset();
}
static string _ReadAccountNumber()
{
string AccountNumber = "";
cout << clsColor::Text(226) + "\nPlease Enter Account Number To Transfer From : ";
AccountNumber = clsInputValidate::ReadString();
while (!clsBankClient::IsClientExit(AccountNumber))
{
cout << clsColor::Text(112) + "\nAccount Number Is Not Found, Choose Another One : ";
AccountNumber = clsInputValidate::ReadString();
}
return AccountNumber;
}
static float _ReadAmount(clsBankClient SourceClient)
{
float Amount = 0;
cout << clsColor::Text(226) + "\nEnter Transfer Amount : ";
Amount = clsInputValidate::ReadFloatNumber();
while (Amount > SourceClient.AccountBalance || Amount < 0)
{
cout << clsColor::Text(112) + "\nAmount Exceeds The Available Balance, Enter Another Amount : ";
Amount = clsInputValidate::ReadDoubleNumber();
}
return Amount;
}
public :
static void ShowTransferScreen()
{
_DrawScreenHeader(clsColor::Blink() + clsColor::Text(45) + "\t Transfer Screen" + clsColor::Reset());
clsBankClient SourceClient = clsBankClient::Find(_ReadAccountNumber());
_PrintClient(SourceClient);
clsBankClient DestinationClient = clsBankClient::Find(_ReadAccountNumber());
_PrintClient(DestinationClient);
float Amount = _ReadAmount(SourceClient);
cout << clsColor::Text(201) + "\nAre You Sure You Want To Perform This Operation ? Y/N ? ";
char Choice = 'N';
cin >> Choice;
if (Choice == 'y' || Choice == 'Y')
{
if (SourceClient.Transfer(Amount , DestinationClient , CurrentUser.UserName))
{
cout << clsColor::Text(46) + "\nTransfer Done Successfully.\n";
}
else
{
cout << clsColor::Text(196) + "\nTransfer Faild.\n";
}
_PrintClient(SourceClient);
_PrintClient(DestinationClient);
}
else
{
cout << clsColor::Text(196) + "\nThe operation was cancelled.\n";
}
}
};