-
Notifications
You must be signed in to change notification settings - Fork 0
/
Operations_3.cpp
52 lines (47 loc) · 1.42 KB
/
Operations_3.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
#include "Bankomat_1.h"
#include <iostream>
bool Bankomat::put_money(int *money, int n) {
if (open || card == "Not inside") return false;
try{
pair<map<int, int>, int>new_bills = adding_money(bills, money, n);
for (auto it: new_bills.first) bills[it.first] = it.second;
make_deposit(card, new_bills.second);
operations["deposit"] = new_bills.second;
return true;
}
catch (WrongOperation &e) {
throw;
}
}
int Bankomat::give_out_money(int money) {
if (open || card == "Not inside") throw WrongOperation("Please, insert card");
try{
map <int, int> new_bills = issuing_money(bills, money);
for (auto it : new_bills){
bills[it.first] = it.second;
}
if (make_withdrawal(card, money)){
operations["cash withdrawal"] = money;
return money;
}
throw WrongOperation("Not enough money");
}
catch (WrongOperation &e) {
throw;
}
}
int Bankomat::balance() {
if (open || card == "Not inside") throw WrongOperation("The operation is not available");
return check_balance(card);
}
bool Bankomat::make_payment(const string &card1, int money) {
if (open || card == "Not inside") return false;
try{
make_transaction(card, card1, money);
operations["transaction"] = money;
return true;
}
catch (WrongOperation &e) {
throw;
}
}