exe程序
点此下载
功能
- 选课先到先得。
- 具有三个登录模式,分别为教务员、老师、学生。
- 教务员账号 admin 密码 admin。
- 学生教师密码默认 0000 。
- 教务员无权新增课程,但可修改/删除 。
- 课程名最长 40 个字符 。
- 学生和教师姓名最长 20 个字符, 编号 8 位数(学生)6 位数(教师)自动生成且唯一 。
- 本程序涉及到搜索功能的仅支持编号查找 。
- 本程序自带各种输入检查,用户和课程名称可包含空格。
开发环境
- Windows 10 + Visual Studio 2017 Cummunity;
设计
- 建立三个stl库的list容器,数据操作时通过int类型的id相互关联
- 教务员为control类,学生和教师继承interface类,部分差异在派生类中定义
- 单例模式,手动释放
体会
- 该实验单例模式的局限性
- 使用inline函数避免重定义
- 多个函数合体,传参选择响应功能,减少代码量
- 善用algorithm的find_if和find函数,find_if的第三个参数自己定义用于判断的类
- 限定编号位数,输入优先检查位数节省时间
- 注意erase后iter的变化
- 文件读取直接getline,避免与>>运算符混用时一些情况下存在的问题
- http://blog.csdn.net/shenyulv/article/details/6699836
源码
control.h
#ifndef CONTROL_H
#define CONTROL_H
#include<iostream>
#include<string>
#include<list>
#include<sstream>
#include<algorithm>
#include<conio.h>
using namespace std;
struct user {
user(){}
user(string Name, int Id) {
id = Id;
password = "0000";
name = Name;
}
int id;
string password;
string name;
list<int> courseId;
};
struct courseT {
courseT(){}
courseT(string Name, int Limit, int TeacherId, string TeacherName) {
id = count++;
name = Name;
limit = Limit;
teacherId = TeacherId;
teacherName = TeacherName;
}
int id;
string name;
int teacherId;
int limit;
string teacherName;
static int count;
list<int> studentId;
};
class findCourse {
public:
findCourse(int id) :id(id) {}
bool operator()(const courseT &p) {
return id == p.id;
}
private:
int id;
};
class findUser {
public:
findUser(int id) :id(id) {}
bool operator()(const user &p) {
return id == p.id;
}
private:
int id;
};
class control {
public:
void addUser(int p);
void handleUser(int p, int q);
void diplayCourse();
void studentCourse();
void teacherCourse();
void modifyNotice();
void modifyCourse(int p);
void save();
static control* getInstance();
list<user> student;
list<user> teacher;
list<courseT> course;
string notice;
private:
int studentAmount;
int teacherAmount;
control();
static control* instance;
};
#endif
control.cpp
#include<fstream>
#include<string>
#include<sstream>
#include<iostream>
#include<iomanip>
#include"control.h"
#include"global.h"
using namespace std;
int courseT::count = 10000;
control::control() {
studentAmount = 10000000;
teacherAmount = 100000;
ifstream c("student.ini", ios::binary | ios::in);
ifstream o("teacher.ini", ios::binary | ios::in);
ifstream m("course.ini", ios::binary | ios::in);
ifstream e("data.ini", ios::binary | ios::in);
if (c.is_open() && o.is_open() && m.is_open() && e.is_open()) {
while (c.peek() != EOF) {
user tem;
string line1, line4, line5;
getline(c, line1);
getline(c, tem.password);
getline(c, tem.name);
getline(c, line4);
getline(c, line5);
stringstream L1(line1), L4(line4), L5(line5);
L1 >> tem.id;
int size, num;
L4 >> size;
for (int i = 0; i < size; i++) {
L5 >> num;
tem.courseId.push_back(num);
}
student.push_back(tem);
}
c.close();
while (o.peek() != EOF) {
user tem;
string line1, line4, line5;
getline(o, line1);
getline(o, tem.password);
getline(o, tem.name);
getline(o, line4);
getline(o, line5);
stringstream L1(line1), L4(line4), L5(line5);
L1 >> tem.id;
int size, num;
L4 >> size;
for (int i = 0; i < size; i++) {
L5 >> num;
tem.courseId.push_back(num);
}
teacher.push_back(tem);
}
o.close();
while (m.peek() != EOF) {
courseT tem;
string line1, line3, line4, line6, line7;
getline(m, line1);
getline(m, tem.name);
getline(m, line3);
getline(m, line4);
getline(m, tem.teacherName);
getline(m, line6);
getline(m, line7);
stringstream L1(line1), L3(line3), L4(line4), L6(line6), L7(line7);
L1 >> tem.id;
L3 >> tem.limit;
L4 >> tem.teacherId;
int size, num;
L6 >> size;
for (int i = 0; i < size; i++) {
L7 >> num;
tem.studentId.push_back(num);
}
course.push_back(tem);
}
m.close();
e >> studentAmount >> teacherAmount >> courseT::count;
string tem;
getline(e, tem);
getline(e, tem);
while (e.peek() != EOF) {
getline(e, tem);
notice += '\n';
notice += tem;
}
e.close();
}
}
void control::save() {
ofstream o("student.ini", ios::binary | ios::out);
ofstream u("teacher.ini", ios::binary | ios::out);
ofstream t("course.ini", ios::binary | ios::out);
ofstream out("data.ini", ios::binary | ios::out);
if (o.is_open() && u.is_open() && t.is_open() && out.is_open()) {
for (auto &x : student) {
o << x.id << endl << x.password << endl << x.name << endl << x.courseId.size() << endl;
for (auto &y : x.courseId)
o << y << " ";
o << endl;
}
o.close();
for (auto &x : teacher) {
u << x.id << endl << x.password << endl << x.name << endl << x.courseId.size() << endl;
for (auto &y : x.courseId)
u << y << " ";
u << endl;
}
u.close();
for (auto &x : course) {
t << x.id << endl << x.name << endl << x.limit << endl << x.teacherId << endl << x.teacherName << endl << x.studentId.size() << endl;
for (auto &y : x.studentId)
t << y << " ";
t << endl;
}
t.close();
out << studentAmount << endl << teacherAmount << endl << courseT::count << endl << notice << endl;
out.close();
}
else {
cerr << "未知错误,请联系技术员!";
system("pause");
}
}
void control::addUser(int p) {
cout << "姓名:\n";
string name;
getline(cin, name);
if (name.length() == 0|| name.length() > 20) {
cout << "输入有误!";
return;
}
if (p == 0) {
student.push_back(user(name, studentAmount++));
cout << "添加成功!编号:" << studentAmount - 1;
}
else {
teacher.push_back(user(name, teacherAmount++));
cout << "添加成功!编号:" << teacherAmount - 1;
}
}
void control::handleUser(int p, int q) {
cout << "学号/工号:\n";
string idStr;
getline(cin, idStr);
if (idStr.length() != p) {
cout << "输入有误!";
return;
}
int id = stringToNum(idStr);
if (id == -1) {
cout << "输入有误!";
return;
}
if (p == 8) {
auto iter = find_if(student.begin(), student.end(), findUser(id));
if (iter == student.end()) {
cout << "用户不存在";
return;
}
if (q == 0) {
for (auto itor = iter->courseId.begin(); itor != iter->courseId.end(); ++itor) {
auto itar = find_if(course.begin(), course.end(), findCourse(*itor));
itar->studentId.erase(find(itar->studentId.begin(), itar->studentId.end(), id));
}
student.erase(iter);
cout << "成功删除!";
}
else {
cout << "新密码:\n";
string password;
getline(cin, password);
if (password.length() == 0) {
cout << "输入有误!";
return;
}
iter->password = password;
cout << "更改成功!";
}
}
if (p == 6) {
auto iter = find_if(teacher.begin(), teacher.end(), findUser(id));
if (iter == teacher.end()) {
cout << "用户不存在";
return;
}
if (q == 0) {
for (auto itor = iter->courseId.begin(); itor != iter->courseId.end(); ++itor) {
auto itar = find_if(course.begin(), course.end(), findCourse(*itor));
for (auto itur = itar->studentId.begin(); itur != itar->studentId.end(); ++itur) {
auto itir = find_if(student.begin(), student.end(), findUser(*itur));
itir->courseId.erase(find(itir->courseId.begin(), itir->courseId.end(), *itor));
}
stringstream tem;
tem << "\n课程“" << itar->name << "”(编号:" << itar->id << ")已被取消";
notice += tem.str();
int p = -1, count = 0;
while (1) {
p = notice.find('\n', p + 1);
if (p == -1)
break;
count++;
}
if (count == 6)
notice = notice.substr(notice.find('\n', 1), notice.length() - notice.find('\n', 1));
course.erase(itar);
}
teacher.erase(iter);
cout << "删除成功!";
}
else {
cout << "新密码:\n";
string password;
getline(cin, password);
if (password.length() == 0) {
cout << "输入有误!";
return;
}
iter->password = password;
cout << "更改成功!";
}
}
}
void control::diplayCourse() {
if (course.empty()) {
cout << "暂无课程";
return;
}
cout << "编号 课程 教师 人数\n";
for (auto iter = course.begin(); iter != course.end(); iter++)
cout << iter->id << " " << left << setw(40) << iter->name << " " << left << setw(20) << iter->teacherName << " (" << iter->studentId.size() << "/" << iter->limit << ")\n";
}
void control::studentCourse() {
cout << "学号:\n";
string idStr;
getline(cin, idStr);
if (idStr.length() != 8) {
cout << "输入有误!";
return;
}
int id = stringToNum(idStr);
if (id == -1) {
cout << "输入有误!";
return;
}
auto iter = find_if(student.begin(), student.end(), findUser(id));
if (iter == student.end()) {
cout << "用户不存在!";
return;
}
cout << "姓名:\n" << iter->name << "\n\n";
if (iter->courseId.empty()) {
cout << "暂无课程";
return;
}
cout << "编号 课程 教师 人数\n";
for (auto itir = iter->courseId.begin(); itir != iter->courseId.end(); ++itir) {
auto itor = find_if(course.begin(), course.end(), findCourse(*itir));
cout << itor->id << " " << left << setw(40) << itor->name << " " << left << setw(20) << itor->teacherName << " (" << itor->studentId.size() << "/" << itor->limit << ")\n";
}
}
void control::teacherCourse() {
cout << "工号:\n";
string idStr;
getline(cin, idStr);
if (idStr.length() != 6) {
cout << "输入有误!";
return;
}
int id = stringToNum(idStr);
if (id == -1) {
cout << "输入有误!";
return;
}
auto iter = find_if(teacher.begin(), teacher.end(), findUser(id));
if (iter == teacher.end()) {
cout << "用户不存在!";
return;
}
cout << "姓名:\n" << iter->name << "\n\n";
if (iter->courseId.empty()) {
cout << "暂无课程";
return;
}
cout << "编号 课程 人数\n";
for (auto itir = iter->courseId.begin(); itir != iter->courseId.end(); ++itir) {
auto itor = find_if(course.begin(), course.end(), findCourse(*itir));
cout << itor->id << " " << left << setw(40) << itor->name << " (" << itor->studentId.size() << "/" << itor->limit << ")\n";
}
}
void control::modifyNotice() {
cout << "当前:\n" << notice << "\n\n发布:\n";
string n;
getline(cin, n);
if (n.length() == 0) {
cout << "输入有误!";
return;
}
notice += '\n';
notice += n;
int p = -1, count = 0;
while (1) {
p = notice.find('\n', p + 1);
if (p == -1)
break;
count++;
}
if (count == 6)
notice = notice.substr(notice.find('\n', 1), notice.length() - notice.find('\n', 1));
cout << "发布成功!";
}
void control::modifyCourse(int p) {
cout << "课程编号:\n";
string num;
getline(cin, num);
if (num.length() != 5) {
cout << "输入有误!";
return;
}
int id = stringToNum(num);
if (id == -1) {
cout << "输入有误!";
return;
}
auto iter = find_if(course.begin(), course.end(), findCourse(id));
if (iter == course.end()) {
cout << "无此课程";
return;
}
if (p == 0) {
cout << "编号 课程 教师 人数\n";
cout << iter->id << " " << left << setw(40) << iter->name << " " << left << setw(20) << iter->teacherName << " (" << iter->studentId.size() << "/" << iter->limit << ")\n";
}
else if (p == 1) {
cout << "当前:\n" << iter->name << "\n\n更新:\n";
string name;
getline(cin, name);
if (name.length() == 0 || name.length() > 40) {
cout << "输入有误!";
return;
}
iter->name = name;
cout << "更改成功!";
}
else if (p == 2) {
cout << "当前:\n" << iter->limit << "\n\n更新:\n";
string num;
getline(cin, num);
int n = stringToNum(num);
if (n == -1) {
cout << "输入有误!";
return;
}
if (num.length() > 4) {
cout << "超出人数限制!";
return;
}
iter->limit = n;
cout << "更改成功!";
}
else {
auto itor = find_if(teacher.begin(), teacher.end(), findUser(iter->teacherId));
itor->courseId.erase(find(itor->courseId.begin(), itor->courseId.end(), iter->id));
for (auto itur = iter->studentId.begin(); itur != iter->studentId.end(); ++itur) {
auto itir = find_if(student.begin(), student.end(), findUser(*itur));
itir->courseId.erase(find(itir->courseId.begin(), itir->courseId.end(), iter->id));
}
stringstream tem;
tem << "\n课程“" << iter->name << "”(编号:" << iter->id << ")已被取消";
notice += tem.str();
int p = -1, count = 0;
while (1) {
p = notice.find('\n', p + 1);
if (p == -1)
break;
count++;
}
if (count == 6)
notice = notice.substr(notice.find('\n', 1), notice.length() - notice.find('\n', 1));
course.erase(iter);
cout << "删除成功!";
}
}
control* control::instance = NULL;
control* control::getInstance() {
if (instance == NULL)
instance = new control;
return instance;
}
interface.h
#ifndef INTERFACE_H
#define INTERFACE_H
#include"control.h"
class Interface {
public:
Interface(){}
bool login();
void noticeBoard();
void changePassword();
protected:
int role;
user* me;
};
class studentInterface :public Interface {
public:
studentInterface();
void selectCourse();
void displayCourse();
void deleteCourse();
};
class teacherInterface :public Interface {
public:
teacherInterface();
void displayCourse();
void addCourse();
};
#endif
global.h
#ifndef GLOBAL_H
#define GLOBAL_H
#include<conio.h>
#include<string>
#include<sstream>
using namespace std;
inline int stringToNum(string source) {
if (source.length() == 0)
return -1;
for (size_t i = 0; i < source.length(); i++)
if (source[i]<'0' || source[i]>'9')
return -1;
stringstream s(source);
int num;
s >> num;
return num;
}
inline string Password() {
char password[100] = "\0";
int index = 0;
while (1) {
char ch;
ch = _getch();
if (ch == 8) {
if (index != 0) {
std::cout << char(8) << " " << char(8);
index--;
}
}
else if (ch == '\r') {
password[index] = '\0';
cout << endl;
if (password[0] != 0)
break;
}
else {
std::cout << "*";
password[index++] = ch;
}
}
string tem(password);
return tem;
}
#endif
interface.cpp
#include"interface.h"
#include"global.h"
#include<iomanip>
using namespace std;
control* globalInstance = control::getInstance();
bool Interface::login() {
cout << "学号/工号:\n";
string idStr;
getline(cin, idStr);
if (idStr.length() != role) {
cout << "输入有误!";
return false;
}
int id = stringToNum(idStr);
if (id == -1) {
cout << "输入有误!";
return false;
}
list<user>* container = &(globalInstance->student);
if (role == 6)
container = &(globalInstance->teacher);
auto iter = find_if(container->begin(), container->end(), findUser(id));
if (iter == container->end()) {
cout << "用户不存在";
return false;
}
cout << "\n密码:\n";
string password = Password();
if (password != iter->password) {
cout << "密码错误";
return false;
}
me = &(*iter);
cout << "\n" << iter->name << ",欢迎回来!\n";
return true;
}
void Interface::noticeBoard() {
if (globalInstance->notice.length() == 0)
cout << "暂无通知";
else
cout << globalInstance->notice;
}
void Interface::changePassword() {
cout << "新密码:\n";
string password;
getline(cin, password);
if (password.length() == 0) {
cout << "输入有误!";
return;
}
me->password = password;
cout << "更改成功!";
}
studentInterface::studentInterface() { role = 8; }
void studentInterface::selectCourse() {
cout << "课程编号:\n";
string num;
getline(cin, num);
if (num.length() != 5) {
cout << "输入有误!";
return;
}
int id = stringToNum(num);
if (id == -1) {
cout << "输入有误!";
return;
}
auto iter = find(me->courseId.begin(), me->courseId.end(), id);
if (iter != me->courseId.end()) {
cout << "已选该课";
return;
}
auto itor = find_if(globalInstance->course.begin(), globalInstance->course.end(), findCourse(id));
if (itor == globalInstance->course.end()) {
cout << "无此课程";
return;
}
if (itor->studentId.size() == itor->limit) {
cout << "人数已满";
return;
}
me->courseId.push_back(id);
itor->studentId.push_back(me->id);
cout << "选课成功!";
}
void studentInterface::displayCourse() {
if (me->courseId.empty()) {
cout << "暂无课程";
return;
}
cout << "编号 课程 教师 人数\n";
for (auto iter = me->courseId.begin(); iter != me->courseId.end(); ++iter) {
auto itor = find_if(globalInstance->course.begin(), globalInstance->course.end(), findCourse(*iter));
cout << itor->id << " " << left << setw(40) << itor->name << " " << left << setw(20) << itor->teacherName << " (" << itor->studentId.size() << "/" << itor->limit << ")\n";
}
}
void studentInterface::deleteCourse() {
cout << "课程编号:\n";
string num;
getline(cin, num);
if (num.length() != 5) {
cout << "输入有误!";
return;
}
int id = stringToNum(num);
if (id == -1) {
cout << "输入有误!";
return;
}
auto iter = find(me->courseId.begin(), me->courseId.end(), id);
if (iter == me->courseId.end()) {
cout << "未选该课";
return;
}
me->courseId.erase(iter);
auto itor = find_if(globalInstance->course.begin(), globalInstance->course.end(), findCourse(id));
itor->studentId.erase(find(itor->studentId.begin(), itor->studentId.end(), me->id));
cout << "退选成功!";
}
teacherInterface::teacherInterface() { role = 6; }
void teacherInterface::displayCourse() {
if (me->courseId.empty()) {
cout << "暂无课程";
return;
}
cout << "编号 课程 人数\n";
for (auto iter = me->courseId.begin(); iter != me->courseId.end(); iter++) {
auto itor = find_if(globalInstance->course.begin(), globalInstance->course.end(), findCourse(*iter));
cout << itor->id << " " << left << setw(40) << itor->name << " (" << itor->studentId.size() << "/" << itor->limit << ")\n";
}
}
void teacherInterface::addCourse() {
cout << "课程名称:\n";
string name;
getline(cin, name);
if (name.length() == 0|| name.length() > 40) {
cout << "输入有误!";
return;
}
cout << "课容量:\n";
string num;
getline(cin, num);
int n = stringToNum(num);
if (n == -1 || n == 0) {
cout << "输入有误!";
return;
}
if (num.length() > 4) {
cout << "超出人数限制!";
return;
}
globalInstance->course.push_back(courseT(name, n, me->id, me->name));
cout << "添加成功!编号:" << courseT::count - 1;
me->courseId.push_back(courseT::count - 1);
stringstream tem;
tem << "\n" << me->name << "老师发布了“" << name << "”课程,编号:" << courseT::count - 1;
globalInstance->notice += tem.str();
int p = -1, count = 0;
while (1) {
p = globalInstance->notice.find('\n', p + 1);
if (p == -1)
break;
count++;
}
if (count == 6)
globalInstance->notice = globalInstance->notice.substr(globalInstance->notice.find('\n', 1), globalInstance->notice.length() - globalInstance->notice.find('\n', 1));
}
main.cpp
#include<iostream>
#include<stdlib.h>
#include<conio.h>
#include<Windows.h>
#include<string>
#include<sstream>
#include"control.h"
#include"global.h"
#include"interface.h"
using namespace std;
int main() {
cout << "\n\n\n中大伪教务 V1.0 .";
control* Instance = control::getInstance();
Sleep(500);
cout << ".";
Sleep(500);
cout << ".";
Sleep(500);
cout << ".";
Sleep(500);
while (1) {
system("cls");
cout << "\n登录:\n\n 0、退出\n 1、教务\n 2、学生\n 3、教师\n";
int ch = _getch();
if (ch == '0')
break;
else if (ch == '1') {
system("cls");
cout << "\n教务\n\n用户名:\n";
string name;
getline(cin, name);
if (name.length() == 0) {
cout << "输入有误!";
_getch();
continue;
}
cout << "\n密码:\n";
string password = Password();
if (name != "admin" || password != "admin") {
cout << "\n用户名不存在或密码错误";
_getch();
}
else {
cout << "\n登录成功! ...";
Sleep(1000);
while (1) {
system("cls");
cout << "\n教务\n\n 0、返回\n 1、发布公告\n 2、课程管理\n 3、学生管理\n 4、教师管理\n";
int ch = _getch();
if (ch == '0')
break;
else if (ch == '1') {
system("cls");
cout << "\n教务> 发布公告\n\n";
Instance->modifyNotice();
_getch();
}
else if (ch == '2') {
while (1) {
system("cls");
cout << "\n教务> 课程管理\n\n 0、返回\n 1、所有课程\n 2、查找\n 3、修改课名\n 4、修改课容量\n 5、删除课程\n";
int ch = _getch();
if (ch == '0')
break;
else if (ch == '1') {
system("cls");
cout << "\n教务> 课程管理> 所有课程\n\n";
Instance->diplayCourse();
_getch();
}
else if (ch == '2') {
system("cls");
cout << "\n教务> 课程管理> 查找\n\n";
Instance->modifyCourse(0);
_getch();
}
else if (ch == '3') {
system("cls");
cout << "\n教务> 课程管理> 修改课名\n\n";
Instance->modifyCourse(1);
_getch();
}
else if (ch == '4') {
system("cls");
cout << "\n教务> 课程管理> 修改课容量\n\n";
Instance->modifyCourse(2);
_getch();
}
else if (ch == '5') {
system("cls");
cout << "\n教务> 课程管理> 删除课程\n\n";
Instance->modifyCourse(3);
_getch();
}
}
}
else if (ch == '3') {
while (1) {
system("cls");
cout << "\n教务> 学生管理\n\n 0、返回\n 1、添加学生\n 2、删除学生\n 3、查找学生\n 4、修改密码\n";
int ch = _getch();
if (ch == '0')
break;
else if (ch == '1') {
system("cls");
cout << "\n教务> 学生管理> 添加学生\n\n";
Instance->addUser(0);
_getch();
}
else if (ch == '2') {
system("cls");
cout << "\n教务> 学生管理> 删除学生\n\n";
Instance->handleUser(8, 0);
_getch();
}
else if (ch == '3') {
system("cls");
cout << "\n教务> 学生管理> 查找学生\n\n";
Instance->studentCourse();
_getch();
}
else if (ch == '4') {
system("cls");
cout << "\n教务> 学生管理> 修改密码\n\n";
Instance->handleUser(8, 1);
_getch();
}
}
}
else if (ch == '4') {
while (1) {
system("cls");
cout << "\n教务> 教师管理\n\n 0、返回\n 1、添加教师\n 2、删除教师\n 3、查找教师\n 4、修改密码\n";
int ch = _getch();
if (ch == '0')
break;
else if (ch == '1') {
system("cls");
cout << "\n教务> 教师管理> 添加教师\n\n";
Instance->addUser(1);
_getch();
}
else if (ch == '2') {
system("cls");
cout << "\n教务> 教师管理> 删除教师\n\n";
Instance->handleUser(6, 0);
_getch();
}
else if (ch == '3') {
system("cls");
cout << "\n教务> 教师管理> 查找教师\n\n";
Instance->teacherCourse();
_getch();
}
else if (ch == '4') {
system("cls");
cout << "\n教务> 教师管理> 修改密码\n\n";
Instance->handleUser(6, 1);
_getch();
}
}
}
}
}
}
else if (ch == '2') {
system("cls");
studentInterface student;
cout << "\n学生\n\n";
if (!student.login())
_getch();
else {
cout << "登录成功! ...";
Sleep(1000);
while (1) {
system("cls");
cout << "\n学生\n";
student.noticeBoard();
cout << "\n\n 0、返回\n 1、所有课程\n 2、选课\n 3、退课\n 4、已选课程\n 5、修改密码\n";
int ch = _getch();
if (ch == '0')
break;
else if (ch == '1') {
system("cls");
cout << "\n学生> 所有课程\n\n";
Instance->diplayCourse();
_getch();
}
else if (ch == '2') {
system("cls");
cout << "\n学生> 选课\n\n";
student.selectCourse();
_getch();
}
else if (ch == '3') {
system("cls");
cout << "\n学生> 退课\n\n";
student.deleteCourse();
_getch();
}
else if (ch == '4') {
system("cls");
cout << "\n学生> 已选课程\n\n";
student.displayCourse();
_getch();
}
else if (ch == '5') {
system("cls");
cout << "\n学生> 修改密码\n\n";
student.changePassword();
_getch();
}
}
}
}
else if (ch == '3') {
system("cls");
teacherInterface teacher;
cout << "\n教师\n\n";
if (!teacher.login())
_getch();
else {
cout << "\n登录成功! ...";
Sleep(1000);
while (1) {
system("cls");
cout << "\n教师\n";
teacher.noticeBoard();
cout << "\n\n 0、返回\n 1、全校课程\n 2、发布课程\n 3、任教课程\n 4、修改密码\n";
int ch = _getch();
if (ch == '0')
break;
else if (ch == '1') {
system("cls");
cout << "\n教师> 全校课程\n\n";
Instance->diplayCourse();
_getch();
}
else if (ch == '2') {
system("cls");
cout << "\n教师> 发布课程\n\n";
teacher.addCourse();
_getch();
}
else if (ch == '3') {
system("cls");
cout << "\n教师> 任教课程\n\n";
teacher.displayCourse();
_getch();
}
else if (ch == '4') {
system("cls");
cout << "\n教师> 修改密码\n\n";
teacher.changePassword();
_getch();
}
}
}
}
}
system("cls");
cout << "\n\n\n正在保存 .";
Instance->save();
delete Instance;
Sleep(500);
cout << ".";
Sleep(500);
cout << ".";
Sleep(500);
cout << ".";
Sleep(500);
system("cls");
cout << "\n\n\n保存成功!";
Sleep(500);
return 0;
}