机房预约系统搭建
此次系统主要使用的语言为c++语言,使用了部分STL的容器来储存,适合学过一段时间的c++,用来练手。使用的编程软件为vs2019。
基本环境的搭建
针对本次系统我主要搭建了7个头文件,分别来存储computer(机房类),globalFile(存储文件位置宏定义),identity(电脑个人信息),manger(管理员),orderFile(存储文件的形式),student(学生信息),teacher(电脑信息)通过这7个类型,来对系统进行控制存储和预约的信息存储。本次文章将介绍如何建立这7个头文件来对程序进行初期的操作。
computer
机房类储存的主要是电脑的信息只需要两个public类对其进行描述即可,所以设计了一个电脑机房id m_Comid 和 电脑最大数目 m_MAXNum ,来完成对机房的描述
#pragma once
#include<iostream>
using namespace std;
class Computer
{
public:
int m_Comid;
int m_MAXNum;
private:
};
globalFile
此头文件主要是用来对需要存储用到的信息进行宏定义,来命名
#pragma once
#define STUDNENT_FILE "student.txt"
#define ADMIN_FILE "admin.txt"
#define TEACHER_FILE "teacher.txt"
#define COMPUTER_FILE "computer.txt"
#define ORDER_FILE "order.txt"
identity
此头文件表示你的个人信息页面,使用虚函数的方式来对系统的开启菜单进行描述,方便不同菜单在不同机房,不同人员下的改变,同样在公开模式下,定义用户和密码,方便搭建。
#pragma once
#include<iostream>
using namespace std;
#include<string>
#include<fstream>
class Identity
{
public:
virtual void openmenu() = 0;
string m_Name;
string m_Pwd;
};
manger
此类是管理员类的搭建,主要是可以通过管理员的身份,对机房预约的人员进行删减和排查,并且可以查看用户的注册人群和添加和删除用户,此类,相对其他更为复杂。它可以初始化机房的注册人群和使用删除人员等操作。主要使用的容器是vector使用了algorithm头文件。
#pragma once
#include"identity.h"
#include<iostream>
#include<string>
using namespace std;
#include"globalFile.h"
#include<vector>
#include"student.h"
#include"teacher.h"
#include<algorithm>
#include"computer.h"
class Manger:public Identity
{
public:
Manger();
Manger(string name, string pwd);
virtual void openmenu();
void addPerson();
void showPerson();
void showComputer();
void cleanFile();
void initVector();
vector<Student> vStu;
vector<Teacher> vTea;
bool checkRepeat(int id,int type);
vector<Computer> vCom;
void initComputer();
~Manger();
private:
};
orderFile
#pragma once
#include<iostream>
#include<map>
using namespace std;
#include"globalFile.h"
#include<fstream>
#include<string>
class orderFile
{
public:
orderFile();
void updataOrder();
int m_Size;
map<int, map<string, string>> map_Order;
~orderFile();
private:
};
student
#pragma once
#include"identity.h"
#include<iostream>
#include<string>
using namespace std;
#include"globalFile.h"
#include"computer.h"
#include<vector>
#include"orderFile.h"
class Student:public Identity
{
public:
Student();
Student(int id, string name, string pwd);
virtual void openmenu();
void applyOrder();
void showOrder();
void showAllorder();
void cancelOrder();
int m_Id;
vector<Computer> vCom;
void initComputer();
~Student();
private:
};
teacher
#pragma once
#include"identity.h"
#include<iostream>
#include<string>
using namespace std;
#include"globalFile.h"
#include"orderFile.h"
#include<fstream>
#include<vector>
class Teacher :public Identity
{
public:
Teacher();
Teacher(int id, string name, string pwd);
virtual void openmenu();
void showAllorder();
void validOrder();
int m_Empid;
~Teacher();
private:
};
后三个类较为重复,是管理类的简单化,再次不做解释。更多实现请看以后的博客。谢谢你们的观看!