机房预约系统C++

开始之前需要自己在项目目录下创建这几个文件:

1.admin.txt

2.computer.txt

3.order.txt

4.student.txt

5.teacher.txt

1.头文件

1.computer.h

2.globalFile.h

3.identity.h

3.manager.h

4.orderfile.h

5.student.h

6.teacher.h

2.头文件代码

computer.h

#pragma once
#include<iostream>
using namespace std;
class Computer
{
public:
	int m_comId;
	int m_comMax;
};

globalFile.h

#pragma once
#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"

identity.h

#pragma once
#include<iostream>
#include<string>
using namespace std;
class Identity
{
public:
	virtual void operMenu() = 0;
	string m_Name;
	string m_Pwd;
};

manager.h

#pragma once
#include<iostream>
#include"identity.h"
#include<string>
#include<vector>
#include"student.h"
#include"teacher.h"
#include"computer.h"
using namespace std;
class Manager :public Identity
{
public:
	Manager();
	Manager(string name, string pwd);
	virtual void operMenu();
	void AddPerson();
	void ShowPerson();
	void ShowConputer();
	void CleanFile();
	void initvector();
	vector<Student> sV;
	vector<Teacher> tV;
	vector<Computer> cV;
	bool checkRepeat(int id, int type);
	void printvectorS(vector<Student> &sV);
	void printvectorT(vector<Teacher>& tV);

};

orderfile.h

#pragma once
#include<iostream>
#include<map>
#include"globalFile.h"
#include<string>
#include<fstream>
using namespace std;
class OrderFile
{
public:
	OrderFile();
	void updataOrder();
	int m_size;
	map<int, map<string, string>>m_Order;
};

student.h

#pragma once
#include"identity.h"
#include<iostream>
using namespace std;
#include"computer.h"
#include<vector>
class Student :public Identity
{
public:
	Student();
	Student(int id, string  name, string pwd);
	virtual void operMenu();
	void applyOrder();
	void showMyOrder();
	void showAllOrder();
	void cancelOrder();
	int m_id;
	vector<Computer> Cv;
};

teacher.h

#pragma once
#include"identity.h"
#include<iostream>
using namespace std;
class Teacher :public Identity
{
public:
	Teacher();
	Teacher(int empId, string name, string pwd);
	void showAllOrder();
	void validOrder();
	virtual void operMenu();
	void showAllStudentInformation();
	int	m_Empid;
};

3.cpp文件

1.manager.cpp

2.orderfile.cpp

3.student.cpp

4.teacher.cpp

5.机房预约系统.cpp

4.cpp代码

manager.cpp

#include"manager.h"
#include"globalFile.h"
#include<fstream>
#include"student.h"
#include<string>
#include"teacher.h"
#include<algorithm>
Manager::Manager()
{

}
Manager::Manager(string name, string pwd)
{
	this->m_Name = name;
	this->m_Pwd = pwd;
	fstream ifs;
	ifs.open(COMPUTER_FILE, ios::in);
	Computer c;
	while (ifs >> c.m_comId && ifs >> c.m_comMax)
	{
		cV.push_back(c);
	}
}
void Manager::operMenu()
{
	cout << "----------------------------------------------------" << endl;
	cout << "--------|--1.add  account--------------|------------" << endl;
	cout << "--------|--2.view account--------------|------------" << endl;
	cout << "--------|--3.view computer room--------|------------" << endl;
	cout << "--------|--4.clear order---------------|------------" << endl;
	cout << "--------|--0.exit----------------------|------------" << endl;
	cout << "please your choice" << endl;
}
void Manager::AddPerson()
{
	this->initvector();
	A:cout << "please your choice" << endl;
	cout << "1.Add  Student" << endl;
	cout << "2.Add  Teacher" << endl;
	string FileName;
	int choice;
	cin>> choice;
	if (choice == 1)
	{
		B:cout << "please input studentId" << endl;
		int id;
		cin >> id;
		for (vector<Student>::iterator it = sV.begin(); it != sV.end(); it++)
		{
			if (id == it->m_id)
			{
				cout << "Id is Already exists,please input again" << endl;
				cout << "____________________________________________" << endl;
				goto B;
			}
		}
		cout << "please input studentName" << endl;
		string name;
		cin >> name;
		cout << "please input your pwd" << endl;
		string pwd;
		cin >> pwd;
		fstream ofs;
		ofs.open(STUDENT_FILE, ios::out | ios::app);
		ofs<<id << " " << name << " " << pwd << " " << endl;
		cout << "Add Student is sucess" << endl;
		system("pause");
		system("cls");
		ofs.close();
	}
	else if (choice == 2)
	{
		C:cout << "please input teacher's Eid" << endl;
		int eid;
		cin >> eid;
		for (vector<Teacher>::iterator it = tV.begin(); it != tV.end(); it++)
		{
			if (eid == it->m_Empid)
			{
				cout << "Id is Already exists,please input again" << endl;
				cout << "____________________________________________" << endl;
				goto C;
			}
		}
		cout << "please input teacher's name" << endl;
		string name;
		cin >> name;
		cout << "please input your pwd" << endl;
		string pwd;
		cin >> pwd;
		fstream ofs;
		ofs.open(TEACHER_FILE, ios::out | ios::app);
		ofs << eid << " " << name << " " << pwd << " " << endl;
		cout << "Add teacher is sucess" << endl;
		system("pause");
		system("cls");
		ofs.close();
	}
	else
	{
		cout << "your choice is error,please choice again" << endl;
		cout << "________________________________________________" << endl;
		goto A;
	}
}
void printstudent(Student& s)
{
	cout << "Id: " << s.m_id << "  Name : " << s.m_Name << "   Pwd: " << s.m_Pwd << endl;
}
void printteacher(Teacher& t)
{
	cout << "EId: " << t.m_Empid << "  Name : " << t.m_Name << "   Pwd: " << t.m_Pwd << endl;
}
void Manager::ShowPerson()
{
	// There are two ways 
	//The first way to use container iterators 
	A:cout << "please your choice" << endl;
	cout << "1:show student's information" << endl;
	cout << "2:show teacher's information" << endl;
	int choice;
	cin >> choice;
	if (choice == 1)
	{
		this->initvector();
		for_each(sV.begin(), sV.end(),printstudent);
		system("pause");
		system("cls");
		/*this->initvector();
		this->printvectorS(this->sV);*/
		
	}
	else if (choice == 2)
	{
		this->initvector();
		this->printvectorT(this->tV);
		system("pause");
		system("cls");
	}
	else
	{
		cout << "your choice is error.please choice again" << endl;
		goto A;
	}
	//The second way to read the members of the class through the file 
	

	//A:cout << "please your choice" << endl;
	//cout << "1:show student's information" << endl;
	//cout << "2:show teacher's information" << endl;
	//int choice;
	//cin >> choice;
	//if (choice == 1)
	//{
	//	Student s;
	//	fstream ifs;
	//	ifs.open(STUDENT_FILE, ios::in);
	//	while (ifs >> s.m_id && ifs >> s.m_Name && ifs >> s.m_Pwd)  //read file
	//	{
	//		cout <<"Id: " << s.m_id <<"  Name : " << s.m_Name <<"   Pwd: " << s.m_Pwd << endl;
	//	}
	//	system("pause");
	//	system("cls");
	//}
	//else if (choice == 2)
	//{
	//	Teacher t;
	//	fstream ifs;
	//	ifs.open(TEACHER_FILE, ios::in);
	//	while (ifs >> t.m_Empid && ifs >> t.m_Name && ifs >> t.m_Pwd)
	//	{
	//		cout << "EId: " << t.m_Empid << "  Name : " << t.m_Name << "   Pwd: " << t.m_Pwd << endl;
	//	}
	//	system("pause");
	//	system("cls");
	//}
	//else
	//{
	//	cout << "your choice is error,please choice again" << endl;
	//	cout << "______________________________________________" << endl;
	//	goto A;
	//}
}
void Manager::initvector()
{
	sV.clear();
	tV.clear();
	ifstream ifs;
	ifs.open(STUDENT_FILE, ios::in);
	if (!ifs.is_open())
	{
		cout << "File open failed" << endl;
		return;
	}
	Student s;
	while (ifs >> s.m_id && ifs >> s.m_Name && ifs >> s.m_Pwd)
	{
		sV.push_back(s);
	}
	//cout << "Number of current students is:" << sV.size() << endl;
	ifs.close();
	ifs.open(TEACHER_FILE, ios::in);
	Teacher t;
	while (ifs >> t.m_Empid && ifs >> t.m_Name && ifs >> t.m_Pwd)
	{
		tV.push_back(t);
	}
	//cout << "Number of current teachers is :" << tV.size() << endl;
	ifs.close();
}
void Manager::printvectorS(vector<Student> &sV)
{
	cout << "_____________student is information_________________" << endl;
	cout << "Number of current students is:" << sV.size() << endl;
	for (vector<Student>::iterator it = sV.begin(); it != sV.end(); it++)
	{
		cout <<"Id:" << it->m_id <<"  Name:" << it->m_Name <<"  Pwd:" << it->m_Pwd << endl;
	}
	system("pause");
	system("cls");
}
void Manager::printvectorT(vector<Teacher>& tV)
{
	cout << "_____________teacher is information_________________" << endl;
	cout << "Number of current teachers is :" << tV.size() << endl;
	for (vector<Teacher>::iterator it = tV.begin(); it != tV.end(); it++)
	{
		cout << "EId:" << it->m_Empid << "  Name:" << it->m_Name << "  Pwd:" << it->m_Pwd << endl;
	}
	system("pause");
	system("cls");
}
void printComputer(Computer &c)
{
	cout << "computer room serial number:  " << c.m_comId << "   computer's numbers:  "<<c.m_comMax << endl;
}
void Manager::ShowConputer()
{
	cout << "computer roon's information" << endl;
    for_each(cV.begin(), cV.end(), printComputer);
	/*fstream ifs;
	ifs.open(COMPUTER_FILE, ios::in);
	Computer c;
	while (ifs >> c.m_comId && ifs >> c.m_comMax)
	{
		cout << "computer room serial number:  " << c.m_comId << "   computer's numbers:  " << c.m_comMax << endl;
	}*/
	system("pause");
	system("cls");
}
void Manager::CleanFile()
{
	ofstream ofs;
	ofs.open(ORDER_FILE, ios::trunc);
	ofs.close();
	cout << "clear is sucess" << endl;
	system("pause");
	system("cls");
}

orderfile.cpp

#include"orderfile.h"
OrderFile::OrderFile()
{
	fstream ifs;
	ifs.open(ORDER_FILE, ios::in);
	string data;
	string period;
	string stuid;
	string stuname;
	string computernumber;
	string status;
	this->m_size = 0;
	while (ifs >> data && ifs >> period
		&& ifs >> stuid && ifs >> stuname
		&& ifs >> computernumber
		&& ifs >> status)
	{
		/*cout << data << endl;
		cout << period << endl;
		cout << stuid << endl;
		cout << stuname << endl;
		cout << computernumber << endl;
		cout << status << endl;
		cout << endl;*/
		string key;
		string value;
		map<string, string> m;
		//insertOrder(key,value);
		int pos = data.find(":");
		if (pos != -1)
		{
			key = data.substr(0, pos);
			value = data.substr(pos + 1, data.size() - pos - 1);
			m.insert(make_pair(key, value));
		}

		/*cout << key << endl;
		cout << value << endl;*/
		pos = period.find(":");
		if (pos != -1)
		{
			key = period.substr(0, pos);
			value = period.substr(pos + 1, period.size() - pos - 1);
			m.insert(make_pair(key, value));
		}
		pos = period.find(":");
		if (pos != -1)
		{
			key = period.substr(0, pos);
			value = period.substr(pos + 1, period.size() - pos - 1);
			m.insert(make_pair(key, value));
		}
		pos = stuid.find(":");
		if (pos != -1)
		{
			key = stuid.substr(0, pos);
			value = stuid.substr(pos + 1, stuid.size() - pos - 1);
			m.insert(make_pair(key, value));
		}
		pos = stuname.find(":");
		if (pos != -1)
		{
			key = stuname.substr(0, pos);
			value = stuname.substr(pos + 1, stuname.size() - pos - 1);
			m.insert(make_pair(key, value));
		}
		pos = computernumber.find(":");
		if (pos != -1)
		{
			key = computernumber.substr(0, pos);
			value = computernumber.substr(pos + 1, computernumber.size() - pos - 1);
			m.insert(make_pair(key, value));
		}
		pos = status.find(":");
		if (pos != -1)
		{
			key = status.substr(0, pos);
			value = status.substr(pos + 1, status.size() - pos - 1);
			m.insert(make_pair(key, value));
		}
		this->m_Order.insert(make_pair(this->m_size, m));
		this->m_size++;
	}
	ifs.close();
	/*for (map<int, map<string, string>> ::iterator it = m_Order.begin(); it != m_Order.end(); it++)
	{
		cout << "size:" << it->first << "value" << endl;
		for (map<string, string> ::iterator mit = it->second.begin(); mit != it->second.end(); mit++)
		{
			cout << "  key: " << mit->first << "  value: " << mit->second << " ";
		}
		cout << endl;
	}*/
}
//void insertOrder(string x, string y)
//{
//	int pos = x.find(":");
//	if (pos != -1)
//	{
//		y = x.substr(0, pos);
//		y = x.substr(pos + 1, x.size() - pos - 1);
//	}
//}
void OrderFile::updataOrder()
{
	if (this->m_size == 0)
	{
		return;
	}
	ofstream ofs;
	ofs.open(ORDER_FILE, ios::out | ios::trunc);
	for (int i = 0; i < this->m_size; i++)
	{
		ofs << "data:" << m_Order[i]["data"] << " ";
		ofs << "period" << m_Order[i]["period"] << " ";
		ofs << "stuid" << m_Order[i]["stuid"] << " ";
		ofs << "stuname" << m_Order[i]["stuname"] << " ";
		ofs << "computernumber" << m_Order[i]["computernumber"] << " ";
		ofs << "status" << m_Order[i]["status"] << endl;
	}
	ofs.close();
}

student.cpp

#include"student.h"
#include<fstream>
#include"globalFile.h"
#include"orderfile.h"
Student::Student()
{

}
Student::Student(int id, string  name, string pwd)
{
	this->m_id = id;
	this->m_Name = name;
	this->m_Pwd = pwd;
	ifstream ifs;
	ifs.open(COMPUTER_FILE, ios::in);
	Computer c;
	while (ifs >> c.m_comId && ifs >> c.m_comMax)
	{
		Cv.push_back(c);
	}
	ifs.close();
}
void Student::operMenu()
{
	cout << "welcome student represent    " << this->m_Name << "    Login the system" << endl;
	cout << "-------------------------------------------------" << endl;
	cout << "------------|  1: Apply        Order    |---------------------" << endl;
	cout << "------------|  2:View    my    Order    |---------------------" << endl;
	cout << "------------|  3:View    All   Order    |---------------------" << endl;
	cout << "------------|  4:Cancel        Order    |---------------------" << endl;
	cout << "------------|  5:     logout            |---------------------" << endl;
	cout << "please your choice" << endl;
}
void Student::applyOrder()
{
	cout << "please choose data" << endl;
	cout << "1.Monday " << endl;
	cout << "2.Tuesday  " << endl;
	cout << "3.Wednesday  " << endl;
	cout << "4.Thursday  " << endl;
	cout << "5.Friday  " << endl;
	int data;
	while (true)
	{
		cin >> data;
		if (0 < data && data < 6)
		{
			break;
		}
		else
		{
			cout << "your choose is error,please input again" << endl;
		}
	}
	cout << "please choose period " << endl;
	cout << "1.morning " << endl;
	cout << "2.afternoon " << endl;
	int period;
	while (true)
	{
		
		cin >> period;
		if (period == 1)
		{
			break;
		}
		else if (period == 2)
		{
			break;
		}
		else
		{
			cout << "your choose is error,please input again" << endl;
		}
	}
	cout << "please choose computer room" << endl;
	cout << "No. 1 computer room capacity " << Cv[0].m_comMax<< endl;
	cout << "No. 2 computer room capacity " << Cv[1].m_comMax << endl;
	cout << "No. 3 computer room capacity " << Cv[2].m_comMax << endl;
	int computernumber;
	while (true)
	{
		cin >> computernumber;
		if (computernumber > 0 && computernumber < 4)
		{
			break;
		}
		else
		{
			cout << "your choose is error,please input again" << endl;
		}
	}
	cout << "Appointment successful " << endl;
	fstream ofs;
	ofs.open(ORDER_FILE, ios::app);
	ofs << "data:" << data << " ";
	ofs << "period:" << period << " ";
	ofs << "stuId:" << this->m_id << " ";
	ofs << "stuname:" << this->m_Name << " ";
	ofs << "stuPwd:" << this->m_Pwd << " ";
	ofs << "computernumber:" << computernumber << " ";
	ofs << "status:" << 1 << endl;
	ofs.close();
	system("pause");
	system("cls");
}
void Student::showMyOrder()
{
	OrderFile OF;
	if (OF.m_size == 0)
	{
		cout << "No appointment record " << endl;
		system("pause");
		system("cls");
		return;
	}
	for (int i = 0; i < OF.m_size; i++)
	{
		if (OF.m_Order[i]["stuname"] == this->m_Name)
		{	
			cout << "appointment's data: " << OF.m_Order[i]["data"];
			cout << "  period:" << (OF.m_Order[i]["period"] == "1" ? "Morning " : "Afternoon");
			cout << "  computer room : " << OF.m_Order[i]["computernumber"]<<"  ";
			string status = "state:";
			if (OF.m_Order[i]["status"] == "1")
			{
				status += " under review ";
			}
			else if (OF.m_Order[i]["status"] == "2")
			{
				status += " review sucess";
			}
			else if (OF.m_Order[i]["status"] == "-1")
			{
				status += " review false";
			}
			cout << status << endl;
		}
	}
	system("pause");
	system("cls");
}
void Student::showAllOrder()
{

	OrderFile OF;
	if (OF.m_size == 0)
	{
		cout << "No appointment record " << endl;
		system("pause");
		system("cls");
		return;
	}
	for (int i = 0; i < OF.m_size; i++)
	{
			cout << "appointment's data: " << OF.m_Order[i]["data"];
			cout << "  period:" << (OF.m_Order[i]["period"] == "1" ? "Morning " : "Afternoon");
			cout << "  computer room : " << OF.m_Order[i]["computernumber"] << "  ";
			string status = "state:";
			if (OF.m_Order[i]["status"] == "1")
			{
				status += " under review ";
			}
			else if (OF.m_Order[i]["status"] == "2")
			{
				status += " review sucess";
			}
			else if (OF.m_Order[i]["status"] == "-1")
			{
				status += " review false";
			}
			cout << status << endl;
	}
	system("pause");
	system("cls");
}
void Student::cancelOrder()
{

}

teacher.h

#include"teacher.h"
#include<fstream>
#include"globalFile.h"
#include"orderfile.h"
#include"student.h"
Teacher::Teacher()
{

}
Teacher::Teacher(int empId, string name, string pwd)
{
	this->m_Empid = empId;
	this->m_Name = name;
	this->m_Pwd = pwd;
}
void Teacher::operMenu()
{
	cout << "________________________________" << endl;
	cout << "-----|  1.View student information |---------" << endl;;
	cout << "-----|  2.view appointment record|-----------" << endl;
	cout << "-----|  3.Modify appointment record|-----------" << endl;
	cout << "__________________________________" << endl;
	cout << "please input your choose" << endl;
}
void Teacher::showAllStudentInformation()
{
	ifstream ifs;
	ifs.open(STUDENT_FILE, ios::in);
	int id;
	string name;
	string pwd;
	while (ifs >> id && ifs >> name && ifs >> pwd)
	{
		cout << "id:" << id << "  name:" << name << "  pwd:" << pwd << endl;
	}
}
void Teacher::showAllOrder()
{
	OrderFile OF;
	if (OF.m_size == 0)
	{
		cout << "No appointment record " << endl;
		system("pause");
		system("cls");
		return;
	}
	Student s;
	string Sname;
	cout << "please input your need to edit's student name" << endl;
	cin >> Sname;
	for (int i = 0; i < OF.m_size; i++)
	{
		/*if (OF.m_Order[i]["stuname"] == this->m_Name)
		{*/
		if (OF.m_Order[i]["stuname"] == Sname)
		{
			cout << "appointment's data:" << OF.m_Order[i]["data"];
			cout << " period:" << (OF.m_Order[i]["period"] == "1" ? "Morning " : "Afternoon");
			cout << " stuid:" << OF.m_Order[i]["stuid"];
			cout << " stuname:" << OF.m_Order[i]["stuname"];
			cout << " computer room :" << OF.m_Order[i]["computernumber"] << "  ";
			string status = "state:";
			if (OF.m_Order[i]["status"] == "1")
			{
				status += "under review ";
			}
			else if (OF.m_Order[i]["status"] == "2")
			{
				status += "review sucess";
			}
			else if (OF.m_Order[i]["status"] == "-1")
			{
				status += "review false";
			}
			cout << status << endl;
		}
			
		/*}*/
	}
	system("pause");
	system("cls");
}
void Teacher::validOrder()
{

}

机房预约系统.cpp

#include<iostream>
using namespace std;
#include"identity.h"
#include<fstream>
#include"student.h"
#include"globalFile.h"
#include"teacher.h"
#include"manager.h"
void managerMenu(Identity*& manager)
{
	while (true)
	{
		manager->operMenu();
		Manager* man = (Manager*)manager;
		int choice;
		cin >> choice;
		if (choice == 1)
		{
			//cout << "add accout" << endl;
			man->AddPerson();
			//Add account 
		}
		else if (choice == 2)
		{
			//cout << "view accout" << endl;
			man->ShowPerson();
			//View account 
		}
		else if (choice == 3)
		{
			//cout << "view computer room" << endl;
			man->ShowConputer();
			//View computer room 
		}
		else if (choice == 4)
		{
			//cout << "clear order" << endl;
			man->CleanFile();
			//clear order
		}
			/*else if (choice == 0)
			{
				cout << "welcome to again" << endl;
				return;
			}*/
		else
		{
			delete manager;  //delete opject
			cout << "delete is sucess" << endl;
			system("pause");
			system("cls");
			return;
		}
	}	
}
void showstudentMenu(Identity * &student)
{
	while (true)
	{
		student->operMenu();
		Student* man = (Student*)student;
		int choice;
		cin >> choice;
		if (choice ==1)
		{
			man->applyOrder();
		}
		else if (choice == 2)
		{
			man->showMyOrder();
		}
		else if (choice == 3)
		{
			man->showAllOrder();
		}
		else if (choice == 4)
		{
			man->cancelOrder();
		}
		else
		{
			delete student;  //delete opject
			cout << "delete is sucess" << endl;
			system("pause");
			system("cls");
			return;
		}
	}
	
}
void showtercherMenu(Identity*& teacher)
{
	while (true)
	{
		teacher->operMenu();
		Teacher* man = (Teacher*)teacher;
		int choice;
		cin >> choice;
		if (choice == 1)
		{
			man->showAllStudentInformation();
		}
		if (choice == 2)
		{
			man->showAllOrder();
		}
		if (choice == 3)
		{
			man->validOrder();
		}
	}
}
void LoginIn(string FileName, int type)
{
	Identity* Person = NULL;
	ifstream ifs;
	ifs.open(FileName, ios::in);
	if (!ifs.is_open())
	{
		cout << "file does not exist" << endl;
		ifs.close();
		return;	
	}
	int id = 0;
	string name;
	string pwd;
	if (type == 1)
	{
		cout << "please input your study id" << endl;
		cin >> id;
	}
	else if (type == 2)
	{
		cout << "please input your employee's id" << endl;
		cin >> id;
	}
	cout << "please admin's name" << endl;
	cin >> name;	
	cout << "please your pwd" << endl;
	cin >> pwd;
	if (type == 1)
	{
		int sid;
		string sname;
		string spwd;
		while (ifs >> sid && ifs >> sname && ifs >> spwd)
		{
			if (sid == id && sname == name && spwd == pwd)
			{
				cout << "Student Login in is sucess" << endl;
				system("pause");
				system("cls");
				Person = new Student(sid, sname, spwd);
				showstudentMenu(Person);
				return;
			}
		}
	}
	else if (type == 2)
	{
		int tEid;
		string tname;
		string tpwd;
		while (ifs >> tEid && ifs >> tname && ifs >> tpwd)
		{
			if (tEid == id && tname == name && tpwd == pwd)
			{
				cout << "Teacher Login in is sucess" << endl;
				system("pause");
				system("cls");
				Person = new Teacher(tEid, tname, tpwd);
				showtercherMenu(Person);
				return;
			}
		}
	}
	else if (type == 3)
	{
		string Aname;
		string Apwd;
		while (ifs >> Aname && ifs >> Apwd)
		{
			if (Aname == name && Apwd == pwd)
			{
				cout << "Admin Login in is sucess" << endl;
				system("pause");
				system("cls");
				Person = new Manager(Aname, Apwd);
				managerMenu(Person);
				return;
			}
		}
	}
	cout << "login is false" << endl;
	system("pause");
	system("cls");
	return;
}
int main()
{
	while (true)
	{
	cout << "---Welcome to the computer room reservation system --" << endl;
	cout << "---------| 1.Student       login |-------" << endl;
	cout << "---------| 2.Teacher       login |-------" << endl;
	cout << "---------| 3.Administrator login |-------" << endl;
	cout << "---------| 0.Exit         System |-------" << endl;
	cout << "-----------------------------------" << endl;
		cout << "please input your choice" << endl;
		int choice;
		cin >> choice;
		switch (choice)
		{
		case 1:
			LoginIn(STUDENT_FILE, 1);
			break;
		case 2:
			LoginIn(TEACHER_FILE, 2);
			break;
		case 3:
			LoginIn(ADMIN_FILE, 3);
			break;
		case 0:
			cout << "welcome to next" << endl;
			system("pasue");
			exit(0);
			break;
		default:
			cout << "your choice is error,please choice again" << endl;
			system("pause");
			system("cls");
			break;
		}
	}
	
}

  • 6
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值