-
Notifications
You must be signed in to change notification settings - Fork 0
/
clsTransferScreen.h
92 lines (69 loc) · 2.33 KB
/
clsTransferScreen.h
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
#pragma once
#include <iostream>
#include "clsScreen.h"
#include "clsPerson.h"
#include "clsBankClient.h"
#include "clsInputValidate.h"
class clsTransferScreen :protected clsScreen
{
private:
static void _PrintClient(clsBankClient Client)
{
cout << "\nClient Card:";
cout << "\n___________________\n";
cout << "\nFull Name : " << Client.FullName();
cout << "\nAcc. Number : " << Client.AccountNumber();
cout << "\nBalance : " << Client.AccountBalance;
cout << "\n___________________\n";
}
static string _ReadAccountNumber()
{
string AccountNumber;
cout << "\nPlease Enter Account Number to Transfer From: ";
AccountNumber = clsInputValidate::ReadString();
while (!clsBankClient::IsClientExist(AccountNumber))
{
cout << "\nAccount number is not found, choose another one: ";
AccountNumber = clsInputValidate::ReadString();
}
return AccountNumber;
}
static float ReadAmount(clsBankClient SourceClient)
{
float Amount;
cout << "\nEnter Transfer Amount? ";
Amount = clsInputValidate::ReadFloatNumber();
while (Amount > SourceClient.AccountBalance)
{
cout << "\nAmount Exceeds the available Balance, Enter another Amount ? ";
Amount = clsInputValidate::ReadDblNumber();
}
return Amount;
}
public:
static void ShowTransferScreen()
{
_DrawScreenHeader("\tTransfer Screen");
clsBankClient SourceClient = clsBankClient::Find(_ReadAccountNumber());
_PrintClient(SourceClient);
clsBankClient DestinationClient = clsBankClient::Find(_ReadAccountNumber());
_PrintClient(DestinationClient);
float Amount = ReadAmount(SourceClient);
cout << "\nAre you sure you want to perform this operation? y/n? ";
char Answer = 'n';
cin >> Answer;
if (Answer == 'Y' || Answer == 'y')
{
if (SourceClient.Transfer(Amount, DestinationClient, CurrentUser.UserName))
{
cout << "\nTransfer done successfully\n";
}
else
{
cout << "\nTransfer Faild \n";
}
}
_PrintClient(SourceClient);
_PrintClient(DestinationClient);
}
};