-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaccount.cpp
More file actions
74 lines (58 loc) · 1.67 KB
/
Copy pathaccount.cpp
File metadata and controls
74 lines (58 loc) · 1.67 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
//
// Created by 房诗涵 on 2022/12/10.
//
#include "account.h"
#include "linkList.h"
#include <string>
#include <cstring>
//权限 符号常量 对应{0} {1} {3} {7}
enum Privilege{visitor,customer,clerk,host};
//默认构造:全空
ID::ID() {
memset(userID,0, sizeof(userID));
}
//由char*初始化
ID::ID(char* id) {
strcpy(userID,id);
}
bool ID::operator>(const ID &id) const {
return strcmp(userID,id.userID)>0;
}
bool ID::operator==(const ID &id) const {
return !strcmp(userID,id.userID);
}
bool ID::operator>=(const ID &id) const {
return strcmp(userID,id.userID)>=0;
}
ID &ID::operator=(const ID &id) = default;
ID::~ID() = default;
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
bool account::operator>(const account &id) const {
ID id1 = GetKey();
ID id2 = id.GetKey();
if (id1 > id2) return true;
else return false;
}
ID account::GetKey() const {
return userID;
}
AccountManager::AccountManager() {
}
void AccountManager::AddUser(std::string &UserID, std::string &Password, int Privilege, std::string &Username) {
//create an account
account userAccount;
userAccount.privilege = Privilege;
StringToChar(Username, userAccount.name);
ID userID;
StringToChar(UserID, userID.userID);
userAccount.userID = userID;
StringToChar(Password, userAccount.password);
//insert
accountList.Insert(userID,userAccount);
}
void AccountManager::DeleteUser(std::string &UserID) {
accountList.Erase(UserID);
}
account AccountManager::FindAccount(const std::string &UserID) {
return accountList.FindKey(UserID);
}