-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBank.h
84 lines (78 loc) · 2.02 KB
/
Bank.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
//
// Created by nikit on 14.12.2021.
//
#ifndef ATM_BANK_H
#define ATM_BANK_H
#include<string>
#include<vector>
#include "BankAccount.h"
#include "Admin.h"
#include "AccountsDatabaseParser.h"
class Bank
{
protected:
std::vector<BankAccount> BankAccountVector;
virtual void Money_Withdrawal(std::string card, unsigned int amount)
{
for(int i=0; i<BankAccountVector.size(); i++)
{
if(BankAccountVector[i].CardNumber==card)
{
BankAccountVector[i]-=amount;
}
}
}
void Money_Crediting(std::string card, unsigned int amount)
{
for(int i=0; i<BankAccountVector.size(); i++)
{
if(BankAccountVector[i].CardNumber==card)
{
BankAccountVector[i]+=amount;
}
}
}
void Money_Transfer(std::string cardout, std::string cardin, unsigned int amount)
{
BankAccount *a;
BankAccount *b;
for(int i=0; i<BankAccountVector.size(); i++)
{
if(BankAccountVector[i].CardNumber==cardout)
{
*a=BankAccountVector[i];
}
}
for(int i=0; i<BankAccountVector.size(); i++)
{
if(BankAccountVector[i].CardNumber==cardin)
{
*b=BankAccountVector[i];
}
}
a-=amount;
b+=amount;
}
Bank()
{
AccountsDatabaseParser p;
std::vector<Account> accs=p.GetAccountsInfo();
for(int i=0; accs.size(); i++)
{
BankAccount b(accs[i].getMoneyAmount(), accs[i].getCardPin(), accs[i].getCardNumber());
BankAccountVector.push_back(b);
}
}
BankAccount* GetBankAccountLink(std::string Cardnumber)
{
for(int i=0; i<BankAccountVector.size(); i++)
{
if(BankAccountVector[i].GetCardnumber()==Cardnumber)
{
return &BankAccountVector[i];
}
}
}
friend class Admin;
};
#endif //ATM_BANK_H