Repository navigation
Expand file tree
/
Copy pathbookInformationQqueryMenu.cpp
More file actions
201 lines (184 loc) · 3.89 KB
/
Copy pathbookInformationQqueryMenu.cpp
File metadata and controls
201 lines (184 loc) · 3.89 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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
#include "bookInformationQqueryMenu.h"
#include "borrowingInformationQqueryMenu.h"
/// <summary>
/// 4.图书信息查询二级菜单
/// </summary>
/// <param name="books"></param>
/// <param name="Borrowers"></param>
/// <param name="nBookNum"></param>
void bookInformationQquery_Menu(vector<Person>& Borrowers, vector<Book>& Books)
{
int nSortChoose;
while (1)
{
system("CLS");
printf("\t\t----------------------------------\n");
printf("\t\t|********图书信息查询模块********|\n");
printf("\t\t| |\n");
printf("\t\t| 1.按编号查询 |\n");
printf("\t\t| |\n");
printf("\t\t| 2.按标题查询 |\n");
printf("\t\t| |\n");
printf("\t\t| 3.按作者查询 |\n");
printf("\t\t| |\n");
printf("\t\t| 4.按出版社查询 |\n");
printf("\t\t| |\n");
printf("\t\t| 5.查看所有的图书 |\n");
printf("\t\t| |\n");
printf("\t\t| 0.返回上级菜单 |\n");
printf("\t\t| |\n");
printf("\t\t----------------------------------\n");
printf("\t\t 请选择功能序号(0~4):");
//读入用户选择
//scanf("%d", &nSortChoose);
cin >> nSortChoose;
switch (nSortChoose)
{
case 1:
//4.1 按编号查询
idSearchBook(Books);
system("PAUSE");
break;
case 2:
//4.2 按标题查询
titleSearchBook(Books);
system("PAUSE");
break;
case 3:
//4.3 按作者查询
authorSearchBook(Books);
system("PAUSE");
break;
case 4:
//4.4 按出版社查询
pressSearchBook(Books);
system("PAUSE");
break;
case 5:
//3.1 所有图书借阅情况
allBooksInformation(Books);
system("PAUSE");
break;
case 0:
return;
break;
default:printf("\t\t选择有误,请重选!\n");
}//switch结束
}//while(1)结束
}
/// <summary>
/// 4.1 按编号查询
/// </summary>
/// <param name="Books"></param>
void idSearchBook(vector<Book>& Books)
{
int temp_ID;
cout << "当前为ID搜索图书模式" << endl;
cout << "请输入要搜索的ID:";
cin >> temp_ID;
for (Book temp_book : Books)
{
if (temp_book.searchBookID(temp_ID))
{
cout << "搜索成功" << endl;
display_book_title();
temp_book.display();
return;
}
}
cout << "搜索失败,请检查ID是否正确" << endl;
}
/// <summary>
/// 4.2 按标题查询
/// </summary>
/// <param name="Books"></param>
void titleSearchBook(vector<Book>& Books)
{
bool status = false;
string title;
cout << "当前为书名搜索图书模式" << endl;
cout << "请输入要搜索的书名:";
cin >> title;
display_book_title();
for (Book temp_book : Books)
{
if (temp_book.Title == title)
{
temp_book.display();
status = true;
}
}
if (status)
{
cout << "搜索完毕" << endl;
return;
}
else
{
cout << "未搜索到结果" << endl;
}
}
/// <summary>
/// 4.3 按作者查询
/// </summary>
/// <param name="Books"></param>
void authorSearchBook(vector<Book>& Books)
{
bool status = false;
string author;
cout << "当前为作者搜索图书模式" << endl;
cout << "请输入要搜索的作者:";
cin >> author;
display_book_title();
for (Book temp_book : Books)
{
for (string temp_author : temp_book.Author)
{
if (temp_author == author)
{
temp_book.display();
status = true;
continue;
}
}
}
if (status)
{
cout << "搜索完毕" << endl;
return;
}
else
{
cout << "未搜索到结果" << endl;
}
}
/// <summary>
/// 4.4 按出版社查询
/// </summary>
/// <param name="Books"></param>
void pressSearchBook(vector<Book>& Books)
{
bool status = false;
string press;
cout << "当前为出版社搜索图书模式" << endl;
cout << "请输入要搜索的出版社:";
cin >> press;
display_book_title();
for (Book temp_book : Books)
{
if (temp_book.Press == press)
{
temp_book.display();
status = true;
}
}
if (status)
{
cout << " 搜索完毕" << endl;
return;
}
else
{
cout << " 未搜索到结果" << endl;
}
}