-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAccount.cpp
More file actions
87 lines (78 loc) · 1.19 KB
/
Account.cpp
File metadata and controls
87 lines (78 loc) · 1.19 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
77
78
79
80
81
82
83
84
85
86
87
#include <iostream>
#include <string>
#include "Account.h"
using namespace std;
Account::Account()
{
name;
password;
}
Account::Account(string n, int p)
{
name = n;
password = p;
}
Account::Account(const Account& theOther)
{
name = theOther.name;
password = theOther.password;
}
bool Account::operator !=(int i)
{
if (password == i)
{
return false;
}
return true;
}
bool Account::operator ==(string s)
{
if (name == s)
{
return true;
}
return false;
}
bool Account::operator !=(string s)
{
if (name == s)
{
return false;
}
return true;
}
bool Account::operator ==(char c)
{
if (type==c)
{
return true;
}
return false;
}
void Account::print()
{
cout << " NAME: " << name << " PASSWORD " << password << endl;
}
void Account::save(ostream& os)
{
os << type << ';' << password << ';' << name << endl;
}
void Account::load(istream& is)
{
string name; int password; char c;
is >> c;
if (c != ';') is.clear(ios::failbit);
is >> password;
is >> c;
if (c != ';') is.clear(ios::failbit);
is >> name;
if (is)
{
this->name = name;
this->password = password;
}
else
{
cerr << "Error in input format." << endl;
}
}