-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
71 lines (68 loc) · 2.19 KB
/
Copy pathmain.cpp
File metadata and controls
71 lines (68 loc) · 2.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
#include <iostream>
#include "src/strScanner.h"
#include "src/error.cpp"
#include "src/book.h"
#include "src/user.h"
#include "src/diary.h"
#include "src/linkedList.h"
/*
# 基础指令
quit
exit
# 帐户系统指令
su [UserID] ([Password])?
logout
register [UserID] [Password] [Username]
passwd [UserID] ([CurrentPassword])? [NewPassword]
useradd [UserID] [Password] [Privilege] [Username]
delete [UserID]
# 图书系统指令
show (-ISBN=[ISBN] | -name="[BookName]" | -author="[Author]" | -keyword="[Keyword]")?
buy [ISBN] [Quantity]
select [ISBN]
modify (-ISBN=[ISBN] | -name="[BookName]" | -author="[Author]" | -keyword="[Keyword]" | -price=[Price])+
import [Quantity] [TotalCost]
# 日志系统指令
show finance ([Count])?
log*/
bool exitFlag = false;
int main()
{
std::string working;
init();
initDiary();
while (!exitFlag && getline(std::cin, working))
{
try{
// std::cout<<working<<'\n';
strScanner scanner(working);
std::string op = scanner.nextStr();
if (op.empty()) continue;
if (op == "quit" || op == "exit") exitFlag = true;
else if (op == "su") {su(scanner); bookIn();}
else if (op == "logout") {user_logout(); bookOut();}
else if (op == "register") registerUser(scanner);
else if (op == "passwd") passwd(scanner);
else if (op == "useradd") useradd(scanner);
else if (op == "delete") deleteUser(scanner);
else if (op == "show")
{
std::string tmp = scanner.nextStr_preview();
if (tmp == "finance") showFinance(scanner);
else show(scanner);
}
else if (op == "buy") buy(scanner);
else if (op == "select") select(scanner);
else if (op == "modify") modify(scanner);
else if (op == "import") import(scanner);
else if (op == "log") showFinance(scanner);
else throw error("Invalid");
}
catch (error &obj){
std::cout<<obj.toString()<<'\n';
}
}
writeCount();
return 0;
}
//rm Book_Author_storage Book_ISBN_storage Book_BookName_storage Book_Keyword_storage User_storage