-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreaderfun.cpp
More file actions
154 lines (152 loc) · 3.37 KB
/
Copy pathreaderfun.cpp
File metadata and controls
154 lines (152 loc) · 3.37 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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#include"readerfun.h"
#include"reader.h"
void readerfun::search()
{
reader reader3;//实例化对象
reader3.search();//调用reader类中的search()函数
cout << "是否继续查询(1:是,2:否)" << endl;//循环判断
int a;
do {
cin >> a;
if (a == 1) {
readerfun::search();
}
else if (a == 2) {
return ;
}
else
{
cout << "输入错误,请重新输入!" << endl;
}
} while (a != 1 && a != 2);
}
void readerfun::borrowBook()
{
reader reader4;//实例化对象
for(int a=1;a!=2;){
reader4.borrowBook();//调用reader类中的borrowBook()函数
cout << "是否继续借书(1:是,2:否)" << endl;//循环判断
do {
cin >> a;
if (a == 1)
{
reader4.borrowBook();
}
else if (a == 2) return;
else
{
cout << "输入错误,请重新输入!" << endl;
}
} while (a != 1 && a != 2);
}
}
void readerfun::changeCode()
{
reader reader6;//实例化对象
for (int a = 1; a != 2;)//循环修改密码
{
reader6.changeCode();//调用reader类中的changeCode()函数
cout << "是否继续修改(1:是,2:否)" << endl;//循环判断
do {
cin >> a;
if (a == 1)
{
reader6.changeCode();
}
else if (a == 2)
{
return;
}
else
{
cout << "输入错误,请重新输入!" << endl;//输入错误提示
}
} while (a != 1 && a != 2);
}
}
void readerfun::returnBook() {
reader reader5;//实例化对象
for (int temp = 1; temp;)//循环还书
{
reader5.returnBook();//调用reader类中的returnBook()函数
cout << "是否继续还书(1:是,2:否)" << endl;//循环判断
int a;//定义变量
cin >> a;
do {
if (a == 1) temp = 1;
else if (a == 2) temp = 0;
else
{
cout << "输入错误,请重新输入!" << endl;
temp = 1;//输入错误提示
}
} while (a != 1 && a != 2);
}
}
void readerfun::getStudent()//用于登录账号
{
reader reader5;
int max_attempts = 3; // 最大尝试次数
for (int temp = 1, attempt = 0; temp && attempt < max_attempts; attempt++)
{
int a;//接受getInformation()的返回值
a = reader5.getInformation();//调用reader类中的getInformation()函数
if (a == 1)//登陆成功
{
while (true)
{
system("cls");//清除屏幕内容
cout << "***************************" << endl;
cout << "欢迎进入图书管理系统!" << endl;
cout << "请选择相应功能:" << endl;
cout << "1.查询书籍信息" << endl;
cout << "2.借阅书籍" << endl;
cout << "3.返还书籍" << endl;
cout << "4.退出" << endl;
cout << "***************************" << endl;
int t;
int temp = 0;
do {
if (temp) {
cout << "输入错误,请重新输入!";
}
cin >> t;
temp++;
} while (t != 1 && t != 2 && t != 3 && t != 4);
switch (t)
{
case 1:search(); break;//调用search()函数
case 2:borrowBook(); break;//调用borrowBook()函数
case 3:returnBook(); break;//调用returnBook()函数
case 4:
cout << "感谢您的使用!" << endl;//退出
system("pause");
exit(0);
}
}
}
else
{
if (attempt < max_attempts - 1)
{
cout << "是否继续输入(1:是,2:否)" << endl;//循环判断
int a;//定义变量
cin >> a;
do {
if (a == 1) temp = 1;
else if (a == 2) temp = 0;
else
{
cout << "输入错误,请重新输入!" << endl;
temp = 1;//输入错误提示
}
} while (a != 1 && a != 2);
}
else
{
cout << "你已经尝试了三次,登录失败!" << endl;
temp = 0;
}
}
}
}