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 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265
| #include "Manage.h" #include "VAStudent.h" #include "REStudent.h"
Manage::Manage() { }
Manage::~Manage() { }
void Manage::Menu() { while (true) { int userSelect = this->indexPage(); switch (userSelect) { case 1: userSelect = this->indexPage(1); if (userSelect == -1) break; this->addStdFunc(); break; case 2: userSelect = this->indexPage(2); if (userSelect == -1) break; this->delStdFunc(); break; case 3: userSelect = this->indexPage(3); if (userSelect == -1) break; this->modifyStdFunc(); break; case 4: userSelect = this->indexPage(4); if (userSelect == -1) break; this->showStdFunc(); break; case 5: userSelect = this->indexPage(5); if (userSelect == -1) break; this->searchStdFunc(); break; case 6: userSelect = this->indexPage(6); if (userSelect == -1) break; this->clearStdFunc(); break; case 7: return; break; default: break; } } }
int Manage::indexPage(int index) { system("cls"); std::cout << "\t\t\t#######欢迎使用逆向工程学院管理系统#######" << std::endl; for (size_t i = 0; i < 7; i++) { if (index == 0) { std::cout << "\t\t\t|----------------------------------------|" << std::endl; std::cout << "\t\t\t|\t\t" << (i + 1) << ". " << menuList[i] << "\t\t |" << std::endl; } else { if (index == (i+1)) { std::cout << "\t\t\t|----------------------------------------|" << std::endl; std::cout << "\t\t\t|\t\t" << "1. " << menuList[i] << "\t\t |" << std::endl; std::cout << "\t\t\t|----------------------------------------|" << std::endl; std::string userSelect; std::cout<<"\t\t\t|"<< "输入任意键继续,输入0返回:"; std::cin >> userSelect; if (userSelect == "0") return -1; return 0; } } } std::cout << "\t\t\t|----------------------------------------|" << std::endl;
int userSelect; std::cout << "\t\t\t|请输入选项(1~7): "; std::cin >> userSelect; return userSelect; }
void Manage::addStdFunc() { int userSelect; int sid; std::string name; int className; FLAG: std::cout<< "\t\t\t|请选择专业(1.病毒分析、2.逆向破解):"; std::cin >> userSelect; if (userSelect > 3 || userSelect < 0) goto FLAG; std::cout<< "\t\t\t|请输入学号:"; std::cin >> sid; bool is_null = this->isSidInArr(sid); if (is_null) { std::cout << "\t\t\t|您输入的学号已存在!" << std::endl; goto FLAG; } std::cout << "\t\t\t|请输入姓名:"; std::cin >> name; std::cout << "\t\t\t|请输入班级:"; std::cin >> className; if (userSelect == 1) { this->ArrStds.push_back(new VAStudent(sid,name,className)); }else { this->ArrStds.push_back(new REStudent(sid, name, className)); } std::string yn; std::cout << "\t\t\t|已添加学生信息,是否继续添加?(y/n):"; std::cin >> yn; if (yn == "y") goto FLAG; }
void Manage::delStdFunc() { int del_id; DEL_FLAG: std::cout << "\t\t\t|请输入要删除的学生ID:"; std::cin >> del_id; if (del_id == 0) return; if (!(this->isSidInArr(del_id))) { std::cout << "\t\t\t|您输入的学号不存在,请重新输入 " << std::endl; goto DEL_FLAG; }; for (size_t i = 0; i < this->ArrStds.size(); i++) { if (del_id == ArrStds[i]->sId) { std::string u_scl; std::cout << "\t\t\t|您要删除的学生信息是" << std::endl; ArrStds[i]->showStudentInfo(); std::cout << "\t\t\t|是否确认删除(y/n):"; std::cin >> u_scl; if (u_scl == "y") { this->ArrStds.erase(this->ArrStds.begin() + i); std::cout << "\t\t\t|已删除学生,学号为:"<< del_id << std::endl; } else { goto DEL_FLAG; } } } std::string u_scl; std::cout << "\t\t\t|是否继续删除(y/n):"; std::cin >> u_scl; if (u_scl == "y") goto DEL_FLAG; return; }
void Manage::modifyStdFunc() { FLAG: int u_id; int is_in = false; std::cout << "\t\t\t|请输入要修改的学生ID:"; std::cin >> u_id; if (u_id == 0) return; for (size_t i = 0; i < this->ArrStds.size(); i++) { if (u_id == this->ArrStds[i]->sId) { is_in = true; std::cout << "\t\t\t|您要修改的学生信息如下所示:" << std::endl; this->ArrStds[i]->showStudentInfo(); int new_id; std::cout << "\t\t\t|请输入要修改的学号:"; std::cin >> new_id; if (this->isSidInArr(new_id)) { std::cout << "\t\t\t|您要修改的学号已经存在,不可修改" << std::endl; goto FLAG; } ArrStds[i]->sId = new_id; std::cout << "\t\t\t|学号已经修改成:"<< ArrStds[i]->sId << std::endl; } } if (!is_in) { std::cout<<"\t\t\t|您输入的学号不存在,请查询输入" << std::endl; goto FLAG; } system("pause"); }
void Manage::showStdFunc() { std::cout<<"\t\t\t|全部学生信息如下所示>> " << std::endl; for (size_t i = 0; i < this->ArrStds.size(); i++) { this->ArrStds[i]->showStudentInfo(); } system("pause"); }
void Manage::searchStdFunc() { FLAG: int is_emty = true; int in_id; std::cout << "\t\t\t|请输入学号搜索:"; std::cin >> in_id; std::cout << "\t\t\t|搜索到的学生信息如下所示:" << std::endl; for (size_t i = 0; i < this->ArrStds.size(); i++) { if (in_id == this->ArrStds[i]->sId) { is_emty = false; this->ArrStds[i]->showStudentInfo(); break; } } std::string dd; if (is_emty) { std::cout << "\t\t\t|搜索到的信息为空" << std::endl; } std::cout << "\t\t\t|是否继承搜索(y/n):"; std::cin >> dd; if (dd == "y") goto FLAG; return; }
void Manage::clearStdFunc() { std::string is_claer_std; std::cout << "\t\t\t|是否清空全部学生信息?(y/n)"; std::cin >> is_claer_std; if (is_claer_std == "y") { this->ArrStds.clear(); std::cout << "\t\t\t|学生信息已全部清空." << std::endl; system("pause"); } }
bool Manage::isSidInArr(int sid) { if (this->ArrStds.size() <= 0) return false; for (size_t i = 0; i < this->ArrStds.size(); i++) { if (sid == this->ArrStds[i]->sId) return true; } return false; }
|