-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAccount.cpp
More file actions
139 lines (138 loc) · 2.93 KB
/
Account.cpp
File metadata and controls
139 lines (138 loc) · 2.93 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
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
133
134
135
136
137
138
139
#include"Account.h"
#include"Chuyenbay.h"
#include<iostream>
#include<fstream>
using namespace std;
void Account::setAccount(string acc)
{
this->account = acc;
}
void Account::setPassword(string pass)
{
this->password = pass;
}
string Account::getAccount()
{
return account;
}
string Account::getPassword()
{
return password;
}
Account::Account()
{
next = NULL;
}
Account::~Account() {}
void DanhSachAccount::InpByFile(string name)
{
Account *hientai;
std::ifstream input(name);
string line;
int rows, cols, i;
cols = 2;
for (rows = 0; getline(input, line); ++rows)
{
if (dau == NULL)
{
dau = new Account;
hientai = dau;
}
else
{
hientai->next = new Account;
hientai = hientai->next;
}
i = 1;
string element = "";
if (line.length() == 0)
continue;
for(int t = 0; t < line.length(); ++t)
{
int tmp;
if (line[t] != ' ')
{
element += line[t];
}
else if (line[t] == ' ')
{
if (i == 1)
{
hientai->setAccount(element);
i++;
element = "";
}
else if (i == 2)
{
hientai->setPassword(element);
i++;
element = "";
}
}
}
}
}
void DanhSachAccount::AddNew()
{
Account *hientai;
if (dau == NULL)
{
dau = new Account;
hientai = dau;
}
else
{
hientai = dau;
while (hientai->next != NULL)
{
hientai = hientai->next;
}
hientai->next = new Account;
hientai = hientai->next;
}
string acc, pass;
cout<<"Nhap ten tai khoan: ";
cin>>acc;
cout<<"Nhap mat khau: ";
cin>>pass;
hientai->setAccount(acc);
hientai->setPassword(pass);
}
bool DanhSachAccount::Search_account(string acc)
{
Account *hientai;
hientai = dau;
while (hientai != NULL)
{
if (hientai->getAccount() == acc)
{
return hientai;
}
hientai = hientai->next;
}
return NULL;
}
bool DanhSachAccount::login(string acc,string pass)
{
Account *hientai;
hientai = dau;
while (hientai != NULL)
{
if (hientai->getAccount() == acc && hientai->getPassword() == pass)
{
return true;
}
hientai = hientai->next;
}
return false;
}
void DanhSachAccount::xuat()
{
Account *hientai;
hientai = dau;
while (hientai != NULL)
{
cout<<hientai->getAccount()<<" "<<hientai->getPassword()<<endl;
hientai = hientai->next;
}
}