引言
这个小项目是基于C++的综合知识,主要涵盖了C++的综合知识,有面向对象思想,泛型编程思想,STL的使用,文件的读写等。是为了深入掌握C++而做的一个入门级综合小项目。主要参考了黑马程序员的C++教程,下面是黑马程序员的C++教学视频链接。
黑马程序员C++教程
系统介绍
身份简介
本系统分别有三种身份使用该程序:
1.学生代表:申请使用机房
2.教师:审核学生的预约申请
3.管理员:给学生、教师创建账号
机房简介
机房共有3间
1号机房:最大容量20人
2号机房:最大容量50人
3号机房:最大容量100人
申请简介
申请的订单每周由管理员负责清空
学生可以预约未来一周内的机房使用,预约的日期为周一到周五,预约时需要选择预约时段(上午,下午)
教师来审核预约,依据实际情况审核预约通过或不通过
使用介绍
首先进入登录界面,可选的功能有:
1.学生代表
2.老师
3.管理员
4.退出
每个身份都需要进行验证后,才能进入子菜单。
学生需要输入:学号,姓名,登录密码
老师需要输入:职工号,姓名,登录密码
管理员需要输入:管理员姓名,登录密码
学生具体功能
1.申请预约
2.查看自身预约
3.查看所有预约
4.取消预约
5.注销登录
教师具体功能
1.查看所有预约
2.审核预约
3.注销登陆
管理员具体功能
1.添加账号
2.查看账号
3.查看机房
4.清空预约
5.注销登录
系统需要的类
程序中用到的文件名宏定义如下:
//管理员文件
#define ADMIN_FILE "admin.txt"
//学生文件
#define STUDENT_FILE "student.txt"
//教师文件
#define TEACHER_FILE "teacher.txt"
//机房信息文件
#define COMPUTER_FILE "computer.txt"
//订单文件
#define ORDER_FILE "order.txt"
机房类
#pragma once
#include <iostream>
using namespace std;
class Computer
{
public:
int num_; //机房号
int size_; //容量
};
预约类
#pragma once
#include <string>
#include <fstream>
#include <map>
#include <iostream>
#include "global.h"
using namespace std;
class Order
{
public:
Order();
//更新预约记录
void updateOrder();
//截取键值对
void PutMap(string str,map<string,string>&m);
//记录预约条数
int size_;
//记录预约信息,key记录条数,value记录键值对信息
map<int, map<string, string>> orderdata_;
};
其源文件如下:
#include "order.h"
Order::Order()
{
this->orderdata_.clear();
ifstream ifs;
ifs.open(ORDER_FILE, ios::in);
string date; //日期
string interval; //时间段
string stuid; //学号
string stuname; //姓名
string roomid; //机房号
string status; //预约状态
this->size_ = 0; //初始化记录条数
while (ifs >> date && ifs >> interval && ifs >> stuid
&& ifs >> stuname && ifs >> roomid && ifs >> status) {
map<string, string> m;
m.clear();
this->PutMap(date, m);
this->PutMap(interval, m);
this->PutMap(stuid, m);
this->PutMap(stuname, m);
this->PutMap(roomid, m);
this->PutMap(status, m);
this->size_++;
this->orderdata_.insert(make_pair(this->size_, m));
}
ifs.close();
}
//更新预约记录
void Order::updateOrder()
{
if (this->size_ == 0) {
return;
}
ofstream ofs(ORDER_FILE, ios::out | ios::trunc);
for (int i = 1; i <= this->size_; i++) {
ofs << "date:" << this->orderdata_[i]["date"] << " ";
ofs << "interval:" << this->orderdata_[i]["interval"] << " ";
ofs << "stuid:" << this->orderdata_[i]["stuid"] << " ";
ofs << "stuname:" << this->orderdata_[i]["stuname"] << " ";
ofs << "roomid:" << this->orderdata_[i]["roomid"] << " ";
ofs << "status:" << this->orderdata_[i]["status"] << endl;
}
ofs.close();
}
//截取键值对
void Order::PutMap(string str,map<string, string>& m)
{
string key;
string value;
int pos = str.find(":");
if (pos != -1) {
key = str.substr(0, pos);
value = str.substr(pos + 1, str.size() - pos - 1);
m.insert(make_pair(key, value));
}
}
身份抽象基类
#pragma once
#include <iostream>
#include <string>
using namespace std;
//身份抽象基类
class Identity
{
public:
virtual void OperMenu() = 0; //操作菜单
string name_; //用户名
string password_; //密码
};
管理员类
#pragma once
#include <iostream>
#include <string>
#include <fstream>
#include <vector>
#include <algorithm>
#include "identity.h"
#include "global.h"
#include "student.h"
#include "teacher.h"
#include "computer.h"
using namespace std;
class Admin : public Identity
{
public:
Admin();
Admin(string name, string password);
~Admin();
//选择菜单
virtual void OperMenu();
//添加账号
void AddPerson();
//查看账号
void ShowPerson();
//查看机房信息
void ShowComputer();
//清空预约记录
void ClearFile();
//初始化容器
void InitVector();
//检测是否有重复账号
bool checkRepeat(int id,int type);
vector<Student> stu_;
vector<Teacher> tea_;
vector<Computer> com_;
};
其源文件如下:
#include "admin.h"
Admin::Admin()
{
}
Admin::Admin(string name, string password)
{
this->name_ = name;
this->password_ = password;
this->InitVector();
ifstream ifs;
ifs.open(COMPUTER_FILE, ios::in);
Computer com;
while (ifs >> com.num_ && ifs >> com.size_) {
this->com_.push_back(com);
}
ifs.close();
}
Admin::~Admin()
{
}
//选择菜单
void Admin::OperMenu()
{
cout << "欢迎管理员" << this->name_ << "登录!" << endl;
cout << "\t\t-----------------------------------------\n";
cout << "\t\t| |\n";
cout << "\t\t| 1.添加账号 |\n";
cout << "\t\t| |\n";
cout << "\t\t| 2.查看账号 |\n";
cout << "\t\t| |\n";
cout << "\t\t| 3.查看机房 |\n";
cout << "\t\t| |\n";
cout << "\t\t| 4.清空预约 |\n";
cout << "\t\t| |\n";
cout << "\t\t| 0.注销登录 |\n";
cout << "\t\t| |\n";
cout << "\t\t-----------------------------------------\n";
cout << "请选择您的操作:" << endl;
}
//添加账号
void Admin::AddPerson()
{
string filename; //操作的文件名
string tip; //提示信息
string error;
ofstream ofs;
int select = 0;
cout << "请输入添加账号的类型:1.学生\t2.老师" << endl;
while (true) {
cin >> select;
if (select == 1) {
//学生类型
tip = "请输入学号:";
error = "学号重复,请重新输入!";
filename = STUDENT_FILE;
break;
}
else if (select == 2) {
//老师类型
tip = "请输入工号:";
error = "工号重复,请重新输入!";
filename = TEACHER_FILE;
break;
}
else {
cout << "输入错误,请重新输入!" << endl;
}
}
ofs.open(filename, ios::out | ios::app);
int fid;
string fname;
string fpassword;
cout << tip;
while (true) {
cin >> fid;
bool ret = this->checkRepeat(fid, select);
if (ret) {
cout << error << endl;
}
else {
break;
}
}
cout << "请输入用户名:";
cin >> fname;
cout << "请输入密码:";
cin >> fpassword;
ofs << fid << " " << fname << " " << fpassword << " " << endl;
cout << "添加成功!" << endl;
system("pause");
system("cls");
ofs.close();
this->InitVector();
}
void PrintStu(Student& s)
{
cout << "学号:" << s.id_ << "\t"
<< "姓名:" << s.name_ << "\t"
<< "密码:" << s.password_ << endl;
}
void PrintTea(Teacher& t)
{
cout << "工号:" << t.id_ << "\t"
<< "姓名:" << t.name_ << "\t"
<< "密码:" << t.password_ << endl;
}
//查看账号
void Admin::ShowPerson()
{
cout << "请选择要查看的内容:1.学生\t2.老师" << endl;
int select = 0;
while (true) {
cin >> select;
if (select == 1) {
for_each(this->stu_.begin(), this->stu_.end(), PrintStu);
break;
}
else if (select == 2) {
for_each(this->tea_.begin(), this->tea_.end(), PrintTea);
break;
}
else {
cout << "输入错误,请重新输入!" << endl;
}
}
system("pause");
system("cls");
}
//查看机房信息
void Admin::ShowComputer()
{
cout << "机房信息如下:" << endl;
for (vector<Computer>::iterator it = this->com_.begin(); it != this->com_.end(); ++it) {
cout << "机房号:" << it->num_ << "\t" << "机房最大容量:" << it->size_ << endl;
}
system("pause");
system("cls");
}
//清空预约记录
void Admin::ClearFile()
{
ofstream ofs(ORDER_FILE,ios::trunc);//如果文件存在则删除重建
ofs.close();
cout << "清空成功!" << endl;
system("pause");
system("cls");
}
//初始化容器
void Admin::InitVector()
{
//确保容器为清空状态
stu_.clear();
tea_.clear();
ifstream ifs;
ifs.open(STUDENT_FILE, ios::in);
if (!ifs.is_open()) {
cout << "读取文件失败!" << endl;
return;
}
Student s;
while (ifs >> s.id_ && ifs >> s.name_ && ifs >> s.password_) {
stu_.push_back(s);
}
ifs.close();
ifs.open(TEACHER_FILE, ios::in);
if (!ifs.is_open()) {
cout << "读取文件失败!" << endl;
return;
}
Teacher t;
while (ifs >> t.id_ && ifs >> t.name_ && ifs >> t.password_) {
tea_.push_back(t);
}
ifs.close();
}
//检测是否有重复账号
bool Admin::checkRepeat(int id, int type)
{
if (type == 1) {
//检测学生
for (vector<Student>::iterator it = this->stu_.begin(); it != this->stu_.end(); ++it) {
if (id == it->id_) return true;
}
}
else {
//检测老师
for (vector<Teacher>::iterator it = this->tea_.begin(); it != this->tea_.end(); ++it) {
if (id == it->id_) return true;
}
}
return false;
}
学生类
#pragma once
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
#include "identity.h"
#include "global.h"
#include "computer.h"
using namespace std;
class Student : public Identity
{
public:
Student();
Student(int id,string name,string password);
~Student();
//菜单界面
virtual void OperMenu();
//申请预约
void ApplyOrder();
//查看我的预约
void ShowMyOrder();
//查看所有预约
void ShowAllOrder();
//取消预约
void CancelOrder();
int id_ = 0; //学号
vector<Computer> com_;
};
其源文件如下:
#include "student.h"
#include "order.h"
Student::Student()
{
}
Student::Student(int id, string name, string password)
{
this->id_ = id;
this->name_ = name;
this->password_ = password;
ifstream ifs;
ifs.open(COMPUTER_FILE, ios::in);
Computer c;
while (ifs >> c.num_ && ifs >> c.size_) {
this->com_.push_back(c);
}
ifs.close();
}
Student::~Student()
{
}
//菜单界面
void Student::OperMenu()
{
cout << "欢迎学生" << this->name_ << "登录!" << endl;
cout << "\t\t-----------------------------------------\n";
cout << "\t\t| |\n";
cout << "\t\t| 1.申请预约 |\n";
cout << "\t\t| |\n";
cout << "\t\t| 2.查看我的预约 |\n";
cout << "\t\t| |\n";
cout << "\t\t| 3.查看所有预约 |\n";
cout << "\t\t| |\n";
cout << "\t\t| 4.取消预约 |\n";
cout << "\t\t| |\n";
cout << "\t\t| 0.注销登录 |\n";
cout << "\t\t| |\n";
cout << "\t\t-----------------------------------------\n";
cout << "请选择您的操作:" << endl;
}
//申请预约
void Student::ApplyOrder()
{
cout << "机房开放时间为周一至周五,请选择预约时间:" << endl;
cout << "1.周一\t" << "2.周二\t" << "3.周三\t" << "4.周四\t" << "5.周五" << endl;
int date = 0; //周几
int interval = 0; //上午下午
int num = 0; //几号机房
while (true) {
cin >> date;
if (date >= 1 && date <= 5) {
break;
}
else {
cout << "输入错误,请重新输入!" << endl;
}
}
cout << "请选择预约时间段:1.上午\t2.下午" << endl;
while (true) {
cin >> interval;
if (interval >= 1 && interval <= 2) {
break;
}
else {
cout << "输入错误,请重新输入!" << endl;
}
}
cout << "请选择预约的机房:" << endl;
for (vector<Computer>::iterator it = this->com_.begin(); it != this->com_.end(); ++it) {
cout << it->num_ << "号机房,容量为:" << it->size_ << endl;
}
while (true) {
cin >> num;
if (num >= 1 && num <= 3) {
break;
}
else {
cout << "输入错误,请重新输入!" << endl;
}
}
cout << "预约成功,审核中!" << endl;
ofstream ofs;
ofs.open(ORDER_FILE, ios::app);
ofs << "date:" << date << " ";
ofs << "interval:" << interval << " ";
ofs << "stuid:" << this->id_ << " ";
ofs << "stuname:" << this->name_ << " ";
ofs << "roomid:" << num << " ";
ofs << "status:" << 1 << endl;
ofs.close();
system("pause");
system("cls");
}
//查看我的预约
void Student::ShowMyOrder()
{
Order of;
if (of.size_ == 0) {
cout << "无预约记录" << endl;
system("pause");
system("cls");
return;
}
for (int i = 0; i <= of.size_; i++) {
//c_str() 转 const char*
// atoi (const char*) 转 int
if (this->id_ == atoi(of.orderdata_[i]["stuid"].c_str())) {
cout << "预约日期:周" << of.orderdata_[i]["date"] << "\t";
cout << "时间段:" << (of.orderdata_[i]["interval"] == "1"?"上午":"下午") << "\t";
cout << "学号:" << of.orderdata_[i]["stuid"] << "\t";
cout << "姓名:" << of.orderdata_[i]["stuname"] << "\t";
cout << "机房号:" << of.orderdata_[i]["roomid"] << "\t";
string status;
if (of.orderdata_[i]["status"] == "1") {
status += "审核中";
}
if (of.orderdata_[i]["status"] == "2") {
status += "预约成功";
}
if (of.orderdata_[i]["status"] == "-1") {
status += "预约失败,审核未通过";
}
else {
status += "预约已取消!";
}
cout << "预约状态:" << status << endl;;
}
}
system("pause");
system("cls");
}
//查看所有预约
void Student::ShowAllOrder()
{
Order of;
if (of.size_ == 0) {
cout << "无预约记录" << endl;
system("pause");
system("cls");
return;
}
for (int i = 1; i <= of.size_; i++) {
cout << i << "、";
cout << "预约日期:周" << of.orderdata_[i]["date"] << "\t";
cout << "时间段:" << (of.orderdata_[i]["interval"] == "1" ? "上午" : "下午") << "\t";
cout << "学号:" << of.orderdata_[i]["stuid"] << "\t";
cout << "姓名:" << of.orderdata_[i]["stuname"] << "\t";
cout << "机房号:" << of.orderdata_[i]["roomid"] << "\t";
string status = "状态:";
if (of.orderdata_[i]["status"] == "1") {
status += "审核中";
}
else if (of.orderdata_[i]["status"] == "2") {
status += "预约成功";
}
else if (of.orderdata_[i]["status"] == "-1") {
status += "预约失败,审核未通过";
}
else {
status += "预约已取消!";
}
cout << "预约状态:" << status << endl;
}
system("pause");
system("cls");
}
//取消预约
void Student::CancelOrder()
{
Order of;
if (of.size_ == 0) {
cout << "无预约记录" << endl;
system("pause");
system("cls");
return;
}
cout << "审核中或预约成功的记录可以取消,请输入取消的记录" << endl;
int index = 1; //第几条记录
vector<int> v; //存放在最大容器中的下标编号
for (int i = 0; i <= of.size_; i++) {
if (this->id_ == atoi(of.orderdata_[i]["stuid"].c_str())) {
if (of.orderdata_[i]["status"] == "1" || of.orderdata_[i]["status"] == "2") {
v.push_back(i);
cout << index++ << "、";
cout << "预约日期:周" << of.orderdata_[i]["date"] << "\t";
cout << "时间段:" << (of.orderdata_[i]["interval"] == "1" ? "上午" : "下午") << "\t";
cout << "机房号:" << of.orderdata_[i]["roomid"] << "\t";
string status = "状态:";
if (of.orderdata_[i]["status"] == "1") {
status += "审核中!";
}
else if (of.orderdata_[i]["status"] == "2") {
status += "预约成功!";
}
cout << status << endl;
}
}
}
cout << "请输入要取消的记录,0代表返回" << endl;
int select = 0;
while (true) {
cin >> select;
if (select >= 0 && select <= v.size()) {
if (select == 0) {
break;
}
else {
of.orderdata_[v[select - 1]]["status"] = "0";
of.updateOrder();
break;
}
}
cout << "输入错误,请重新输入!" << endl;
}
system("pause");
system("cls");
}
教师类
#pragma once
#include <iostream>
#include <string>
#include <vector>
#include "identity.h"
#include "order.h"
#define _CRT_SECURE_NO_WARINGS
using namespace std;
class Teacher : public Identity
{
public:
Teacher();
Teacher(int id,string name,string password);
~Teacher();
//菜单界面
virtual void OperMenu();
//查看所有预约
void ShowAllOrder();
//审核预约
void ExamineOrder();
int id_ = 0; //教师编号
};
其源文件如下:
#include "teacher.h"
Teacher::Teacher()
{
}
Teacher::Teacher(int id, string name, string password)
{
this->id_ = id;
this->name_ = name;
this->password_ = password;
}
Teacher::~Teacher()
{
}
//菜单界面
void Teacher::OperMenu()
{
cout << "欢迎老师" << this->name_ << "登录!" << endl;
cout << "\t\t-----------------------------------------\n";
cout << "\t\t| |\n";
cout << "\t\t| 1.查看所有预约 |\n";
cout << "\t\t| |\n";
cout << "\t\t| 2.审核预约 |\n";
cout << "\t\t| |\n";
cout << "\t\t| 0.注销登录 |\n";
cout << "\t\t| |\n";
cout << "\t\t-----------------------------------------\n";
cout << "请选择您的操作:" << endl;
}
//查看所有预约
void Teacher::ShowAllOrder()
{
Order of;
if (of.size_ == 0) {
cout << "无预约记录" << endl;
system("pause");
system("cls");
return;
}
for (int i = 1; i <= of.size_; i++) {
cout << i << "、";
cout << "预约日期:周" << of.orderdata_[i]["date"] << "\t";
cout << "时间段:" << (of.orderdata_[i]["interval"] == "1" ? "上午" : "下午") << "\t";
cout << "学号:" << of.orderdata_[i]["stuid"] << "\t";
cout << "姓名:" << of.orderdata_[i]["stuname"] << "\t";
cout << "机房号:" << of.orderdata_[i]["roomid"] << "\t";
string status = "状态:";
if (of.orderdata_[i]["status"] == "1") {
status += "审核中";
}
else if (of.orderdata_[i]["status"] == "2") {
status += "预约成功";
}
else if (of.orderdata_[i]["status"] == "-1") {
status += "预约失败,审核未通过";
}
else {
status += "预约已取消!";
}
cout << "预约状态:" << status << endl;
}
system("pause");
system("cls");
}
//审核预约
void Teacher::ExamineOrder()
{
Order of;
if (of.size_ == 0) {
cout << "无预约记录" << endl;
system("pause");
system("cls");
return;
}
vector<int> v;
int index = 0;
cout << "待审核的预约记录如下:" << endl;
for (int i = 1; i <= of.size_; i++) {
if (of.orderdata_[i]["status"] == "1") {
v.push_back(i);
cout << ++index << "、";
cout << "预约日期:周" << of.orderdata_[i]["date"] << "\t";
cout << "时间段:" << (of.orderdata_[i]["interval"] == "1" ? "上午" : "下午") << "\t";
cout << "学号:" << of.orderdata_[i]["stuid"] << "\t";
cout << "姓名:" << of.orderdata_[i]["stuname"] << "\t";
cout << "机房号:" << of.orderdata_[i]["roomid"] << "\t";
string status = "状态:审核中";
cout << status << endl;
}
}
cout << "请输入审核的预约记录,0代表返回" << endl;
int select = 0; //接收用户选择的预约记录
int ret = 0; //接收预约结果记录
while (true) {
cin >> select;
if (select >= 0 && select <= v.size()) {
if (select == 0) {
break;
}
else {
cout << "请输入审核结果:1.通过\t2.不通过" << endl;
cin >> ret;
if (ret == 1) {
of.orderdata_[v[select - 1]]["status"] = "2";
}
else {
of.orderdata_[v[select - 1]]["status"] = "-1";
}
of.updateOrder(); //更新预约记录
cout << "审核完毕!" << endl;
break;
}
}
cout << "输入有误,请重新输入!" << endl;
}
system("pause");
system("cls");
}
主函数
#include <iostream>
#include <fstream>
#include <string>
#include "identity.h"
#include "global.h"
#include "student.h"
#include "teacher.h"
#include "admin.h"
using namespace std;
//管理员菜单
void AdminMenu(Identity* &identity)
{
int select = 0;
while (true) {
//显示管理员菜单
identity->OperMenu();
Admin* admin = (Admin*)identity;
cin >> select;
switch (select) {
case 1: //添加账号
admin->AddPerson();
break;
case 2: //查看账号
admin->ShowPerson();
break;
case 3: //查看机房
admin->ShowComputer();
break;
case 4: //清空预约
admin->ClearFile();
break;
default: //注销登录
delete admin;
cout << "注销成功!" << endl;
system("pause");
system("cls");
return;
}
}
}
//学生菜单
void StudentMenu(Identity* &identity)
{
int select = 0;
while (true) {
//显示学生菜单
identity->OperMenu();
Student* student = (Student*)identity;
cin >> select;
switch (select) {
case 1: //申请预约
student->ApplyOrder();
break;
case 2: //查看我的预约
student->ShowMyOrder();
break;
case 3: //查看所有预约
student->ShowAllOrder();
break;
case 4: //取消预约
student->CancelOrder();
break;
default: //注销登录
delete student;
cout << "注销成功!" << endl;
system("pause");
system("cls");
return;
}
}
}
//教师菜单
void TeacherMenu(Identity* &identity)
{
int select = 0;
while (true) {
//显示管理员菜单
identity->OperMenu();
Teacher* teacher = (Teacher*)identity;
cin >> select;
switch (select) {
case 1: //查看所有预约
teacher->ShowAllOrder();
break;
case 2: //审核预约
teacher->ExamineOrder();
break;
default: //注销登录
delete teacher;
cout << "注销成功!" << endl;
system("pause");
system("cls");
return;
}
}
}
//登录函数,参数1为文件名,参数2为登录类型
void LoginIn(string filename, int type)
{
Identity *identity = NULL;
ifstream ifs;
ifs.open(filename, ios::in);
if (!ifs.is_open()) {
cout << "文件不存在!" << endl;
ifs.close();
return;
}
int id = 0;
string name;
string password;
if (type == 1) {
//学生登录
cout << "请输入学号:";
cin >> id;
}
else if (type == 2) {
//教师登录
cout << "请输入工号:";
cin >> id;
}
cout << "请输入用户名:";
cin >> name;
cout << "请输入密码:";
cin >> password;
if (type == 1) {
//学生登录验证
int fid;
string fname;
string fpassword;
//从文件中读取信息
while (ifs >> fid && ifs >> fname && ifs >> fpassword) {
if (fid == id && fname == name && fpassword == password) {
cout << "验证成功!" << endl;
system("pause");
system("cls");
identity = new Student(id, name, password);
StudentMenu(identity); //进入学生子菜单
return;
}
}
}
else if (type == 2) {
//教师登录验证
int fid;
string fname;
string fpassword;
//从文件中读取信息
while (ifs >> fid && ifs >> fname && ifs >> fpassword) {
if (fid == id && fname == name && fpassword == password) {
cout << "验证成功!" << endl;
system("pause");
system("cls");
identity = new Teacher(id, name, password);
TeacherMenu(identity); //进入教师子菜单
return;
}
}
}
else if (type == 3) {
//管理员登录验证
string fname;
string fpassword;
//从文件中读取信息
while (ifs >> fname && ifs >> fpassword) {
if (fname == name && fpassword == password) {
cout << "验证成功!" << endl;
system("pause");
system("cls");
identity = new Admin(name, password);
AdminMenu(identity); //进入管理员子菜单
return;
}
}
}
cout << "验证登录失败!" << endl;
system("pause");
system("cls");
return;
}
int main()
{
int select = 0;
cout << "================ 欢迎来到机房预约系统! ================" << endl;
while (true) {
cout << endl << "请输入您的身份:" << endl;
cout << "\t\t-----------------------------------------\n";
cout << "\t\t| |\n";
cout << "\t\t| 1.学生代表 |\n";
cout << "\t\t| |\n";
cout << "\t\t| 2.老 师 |\n";
cout << "\t\t| |\n";
cout << "\t\t| 3.管 理 员 |\n";
cout << "\t\t| |\n";
cout << "\t\t| 0.退 出 |\n";
cout << "\t\t| |\n";
cout << "\t\t-----------------------------------------\n";
cout << "请输入您的选择:";
cin >> select;
switch (select) {
case 1: //学生
LoginIn(STUDENT_FILE, 1);
break;
case 2: //老师
LoginIn(TEACHER_FILE, 2);
break;
case 3: //管理员
LoginIn(ADMIN_FILE, 3);
break;
case 0: //退出
cout << "欢迎下次使用!" << endl;
system("pause");
system("cls");
return 0;
default:
cout << "输入错误,请重新输入!" << endl;
system("pause");
system("cls");
break;
}
}
system("pause");
return 0;
}
结尾
需要源码的小伙伴可以联系我!