-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDeposit.cpp
More file actions
76 lines (68 loc) · 1.33 KB
/
Deposit.cpp
File metadata and controls
76 lines (68 loc) · 1.33 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
#include <iostream>
#include <string>
#include "Deposit.h"
using namespace std;
Deposit::Deposit()
{
name;
password;
money;
}
Deposit::Deposit(string n, int p, double amount)
{
name = n;
password = p;
money = amount;
}
Deposit::Deposit(const Deposit& other)
{
name = other.name;
password = other.password;
money = other.money;
}
bool Deposit::operator ==(char c)
{
if (type == c)
{
return true;
}
return false;
}
void Deposit::transaction(double amount)
{
if (amount < money)
money = money - amount;
else
cerr << " YOU CAN NOT WITHDRAW MORE THAN YOU HAVE" << endl;
}
void Deposit::print()
{
cout << " NAME: " << name << " PASSWORD " << password << " YOUR DEPOSIT IS: " << money << endl;
}
void Deposit::save(ostream& os)
{
os << type << ';' << password << ';' << money << ';' << name << endl;
}
void Deposit::load(istream& is)
{
string name; int password; double money; char c;
is >> c;
if (c != ';') is.clear(ios::failbit);
is >> password;
is >> c;
if (c != ';') is.clear(ios::failbit);
is >> money;
is >> c;
if (c != ';') is.clear(ios::failbit);
is >> name;
if (is)
{
this->name = name;
this->password = password;
this->money = money;
}
else
{
cerr << "Error in input format." << endl;
}
}