-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCustomer.cpp
134 lines (114 loc) · 2.75 KB
/
Customer.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#include"Customer.h"
#include"Account.h"
#include <iostream>
#include <iomanip>
#include<fstream>
using namespace std;
Customer::Customer() {};
Customer::Customer(string name, string address, string phoneNumber, string email) {
this->name = name;
this->address = address;
this->phone_num = phoneNumber;
this->email = email;
}
void Customer::setName(string name) {
this->name = name;
}
void Customer::setAddress(string adress) {
this->address = adress;
}
void Customer::setPhone_num(string num) {
this->phone_num = num;
}
void Customer::setEmail(string email)
{
this->email = email;
}
string Customer::getName() {
return this->name;
}
string Customer::getAddress() {
return this->address;
}
string Customer::getPhon_num() {
return this->phone_num;
}
string Customer::getEmail()
{
return this->email;
}
void Customer::savedata(Customer c1)
{
ofstream bankfile;
bankfile.open("bank.txt");
bankfile << c1.getName() << "\n";
bankfile << c1.address << "\n";
bankfile << c1.getEmail() << "\n";
bankfile << c1.phone_num << "\n";
bankfile << c1.getBalance() << "\n";
bankfile.close();
}
void Customer::hidendata(Customer c1)
{
ofstream logdata;
logdata.open("log.txt");
logdata << c1.getEmail() << "," << c1.getpass();
}
void Customer::customerinfo(Customer& c)
{
c.loadData(c);
cout << "Name: " << c.getName() << "\n";
cout << "Address: " << c.getAddress() << "\n";
cout << "Email: " << c.getEmail() << "\n";
cout << "Telephone Number: " << c.getPhon_num() << "\n";
cout << "Balance: " << c.getBalance() << "\n";
}
void Customer::transferBalance(Customer& A1, double balance)
{
try {
if (this->balance > balance)
{
this->balance -= balance;
A1.balance += balance;
transactionHistory.push_back("Transfer Balance : $" + to_string(balance));
}
else
{
}
throw exception();
}
catch (exception&) {
cout << "wrong balance";
}
}
void Customer::loadData(Customer& c)
{
ifstream infile("bank.txt");
try {
ifstream infile("bank.txt");
if (infile.is_open()) {
string name, address, email, phon_num;
double balance;
infile >> name >> address >> email >> phon_num >> balance;
c.setName(name);
c.setAddress(address);
c.setEmail(email);
c.setPhone_num(phon_num);
c.setBalance(balance);
infile.close();
}
else
throw exception();
}
catch (exception&) {
cout << "Failed to open file\n";
}
}
void Customer::setpass(string pass)
{
this->pass = pass;
}
string Customer::getpass()
{
return pass;
}