|
|
@ -1,419 +0,0 @@
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include"room.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
struct Dormitory {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int floors;//楼层总数
|
|
|
|
|
|
|
|
int rooms;//每层房间数
|
|
|
|
|
|
|
|
int number;//楼栋号
|
|
|
|
|
|
|
|
vector<Room>room;//本宿舍的寝室房间容器
|
|
|
|
|
|
|
|
Dormitory() {};//默认构造函数
|
|
|
|
|
|
|
|
Dormitory(int fl, int ro, int nu) {
|
|
|
|
|
|
|
|
floors = fl;
|
|
|
|
|
|
|
|
rooms = ro;
|
|
|
|
|
|
|
|
number = nu;
|
|
|
|
|
|
|
|
int weishu = 2;//总房间号位数,与当前房间号位数同理
|
|
|
|
|
|
|
|
for (int f = 1; f <= fl; f++) {
|
|
|
|
|
|
|
|
for (int r = 1; r <= ro; r++) {
|
|
|
|
|
|
|
|
int weishu1=0;//当前房间号位数,本房间号位数没有计算表示楼层的那一位,如寝室号417,不会计算4这一位,仅计算17两位
|
|
|
|
|
|
|
|
for (int i = r; i != 0; i = i / 10) {
|
|
|
|
|
|
|
|
weishu1++;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
string rn;//临时变量
|
|
|
|
|
|
|
|
rn = to_string(r);
|
|
|
|
|
|
|
|
for (int i = 0; i < weishu-weishu1; i++) {
|
|
|
|
|
|
|
|
string temp;
|
|
|
|
|
|
|
|
temp = rn;
|
|
|
|
|
|
|
|
rn ="0"+temp;
|
|
|
|
|
|
|
|
}//生成本房间的本层房间号
|
|
|
|
|
|
|
|
rn =to_string(f)+rn;//在本层房间号前面加上楼层号构成寝室号,如17前加上楼层4,构成寝室号417
|
|
|
|
|
|
|
|
Room Ro(rn);//生成本寝室
|
|
|
|
|
|
|
|
room.push_back(Ro);//将本寝室压入本宿舍楼栋寝室房间容器中
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}//构造函数,添加宿舍楼与读入宿舍信息时使用
|
|
|
|
|
|
|
|
void saveinfo(ofstream &o) {
|
|
|
|
|
|
|
|
o << number << " " << floors << " " << rooms << endl;
|
|
|
|
|
|
|
|
}//写出本宿舍楼楼栋号、楼层数及每层房间数信息,由savaDormitory函数调用
|
|
|
|
|
|
|
|
void saveRoom(ofstream& o) {
|
|
|
|
|
|
|
|
for (vector<Room>::iterator it = room.begin(); it != room.end(); it++) {
|
|
|
|
|
|
|
|
(*it).saveRoom(o);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}//循环写出本宿舍楼各个寝室的信息,由saveDormitory函数调用
|
|
|
|
|
|
|
|
string searchStudent(vector<Dormitory>& d, string id) {
|
|
|
|
|
|
|
|
for (int i = 0; i < room.size(); i++) {
|
|
|
|
|
|
|
|
for (int j = 0; j < 4; j++) {
|
|
|
|
|
|
|
|
if (room[i].stu[j].studentID == id) {
|
|
|
|
|
|
|
|
string s = "学号:" + room[i].stu[j].studentID + " 姓名:" + room[i].stu[j].name + " 性别:" + room[i].stu[j].sex + " 寝室号:" + room[i].roomNumber+"\n";
|
|
|
|
|
|
|
|
return s;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
string o;
|
|
|
|
|
|
|
|
return o;//未查找到该信息,返回空字符串
|
|
|
|
|
|
|
|
}//查询学生信息
|
|
|
|
|
|
|
|
string searchRoom(string rn) {
|
|
|
|
|
|
|
|
for (int i = 0; i < room.size(); i++) {
|
|
|
|
|
|
|
|
if (room[i].roomNumber == rn) {
|
|
|
|
|
|
|
|
string s = room[i].sendinfo();
|
|
|
|
|
|
|
|
return s;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
string o;
|
|
|
|
|
|
|
|
return o;//未查找到该信息,返回空字符串
|
|
|
|
|
|
|
|
}//查询寝室信息
|
|
|
|
|
|
|
|
int judgeFull(string rn) {
|
|
|
|
|
|
|
|
for (int i = 0; i < room.size(); i++) {
|
|
|
|
|
|
|
|
if (room[i].roomNumber == rn) {
|
|
|
|
|
|
|
|
for (int j = 0; j < 4; j++) {
|
|
|
|
|
|
|
|
if (room[i].stu[i].name == "未入住") {
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}//判断宿舍是否已满,用于对进行宿舍调整时对目标寝室是否人满的判断
|
|
|
|
|
|
|
|
int judgeExitS(string na, string id) {
|
|
|
|
|
|
|
|
for (int i = 0; i < room.size(); i++) {
|
|
|
|
|
|
|
|
for (int j = 0; j < 4; j++) {
|
|
|
|
|
|
|
|
if (room[i].stu[j].name == na && room[i].stu[j].studentID == id) {
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}//判断学生是否存在,进行宿舍调整前判断学生信息是否输入正确
|
|
|
|
|
|
|
|
int judgeExitR(string rn) {
|
|
|
|
|
|
|
|
for (int i = 0; i < room.size(); i++) {
|
|
|
|
|
|
|
|
if (room[i].roomNumber == rn) {
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}//判断寝室是否存在,用于查询寝室时判断本宿舍楼是否存在该寝室
|
|
|
|
|
|
|
|
string searchRepair() {
|
|
|
|
|
|
|
|
string o;
|
|
|
|
|
|
|
|
for (int i = 0; i < room.size(); i++) {
|
|
|
|
|
|
|
|
if (room[i].repairReport == true) {
|
|
|
|
|
|
|
|
o = o + "寝室号:" + room[i].roomNumber + " 报修内容:";
|
|
|
|
|
|
|
|
o = o + room[i].breakdown;
|
|
|
|
|
|
|
|
o = o + "\n";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return o;
|
|
|
|
|
|
|
|
}//查询宿舍报修情况
|
|
|
|
|
|
|
|
void clearRoom(vector<Student>& s,string rn) {
|
|
|
|
|
|
|
|
string id[4];
|
|
|
|
|
|
|
|
for (int i = 0; i < room.size(); i++) {
|
|
|
|
|
|
|
|
if (room[i].roomNumber == rn) {
|
|
|
|
|
|
|
|
for (int j = 0; j < 4; j++) {
|
|
|
|
|
|
|
|
id[j] = room[i].stu[j].studentID;
|
|
|
|
|
|
|
|
room[i].stu[j].name = "未入住";
|
|
|
|
|
|
|
|
room[i].stu[j].sex = "不详";
|
|
|
|
|
|
|
|
room[i].stu[j].studentID = "不详";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < s.size(); i++) {
|
|
|
|
|
|
|
|
if (s[i].studentID == id[0] || s[i].studentID == id[1] || s[i].studentID == id[2] || s[i].studentID == id[3]) {
|
|
|
|
|
|
|
|
s.erase(s.begin() + i);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
saveStudent(s);
|
|
|
|
|
|
|
|
readStudent(s);
|
|
|
|
|
|
|
|
}//清空毕业生宿舍,集中体现在清楚学生信息,报修及寝室号信息无需修改,本函数尚未更新文件
|
|
|
|
|
|
|
|
string showEmpty() {
|
|
|
|
|
|
|
|
string o;
|
|
|
|
|
|
|
|
for (int i = 0; i < room.size(); i++) {
|
|
|
|
|
|
|
|
if (room[i].judgeEmpty() == 1) {
|
|
|
|
|
|
|
|
o = o + "寝室号:" + room[i].roomNumber + " 状态:" + "有空床";
|
|
|
|
|
|
|
|
o = o + "\n";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return o;
|
|
|
|
|
|
|
|
}//显示尚有空床的宿舍
|
|
|
|
|
|
|
|
int addStudent(vector<Student>&s,string na, string id, string se) {
|
|
|
|
|
|
|
|
for (int i = 0; i < room.size(); i++) {
|
|
|
|
|
|
|
|
for (int j = 0; j < 4; j++) {
|
|
|
|
|
|
|
|
if (room[i].stu[j].name == "未入住") {
|
|
|
|
|
|
|
|
room[i].stu[j].name = na;
|
|
|
|
|
|
|
|
room[i].stu[j].studentID = id;
|
|
|
|
|
|
|
|
room[i].stu[j].sex = se;
|
|
|
|
|
|
|
|
for (int k = 0; k < s.size(); k++) {
|
|
|
|
|
|
|
|
if (s[k].studentID == id) {
|
|
|
|
|
|
|
|
s[k].dormitoryNumber = number;
|
|
|
|
|
|
|
|
s[k].roomNumber = stoi(room[i].roomNumber.c_str());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;//整栋宿舍楼已无空床可以安排
|
|
|
|
|
|
|
|
}//依次向本楼栋的空床中添加学生
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
void saveDormitory(vector<Dormitory>& d) {
|
|
|
|
|
|
|
|
ofstream ofs;
|
|
|
|
|
|
|
|
ofs.open("Dormitory.txt", ios::out);
|
|
|
|
|
|
|
|
for (vector<Dormitory>::iterator it = d.begin(); it != d.end(); it++) {
|
|
|
|
|
|
|
|
(*it).saveinfo(ofs);
|
|
|
|
|
|
|
|
(*it).saveRoom(ofs);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ofs.close();
|
|
|
|
|
|
|
|
}//写出寝室信息的函数
|
|
|
|
|
|
|
|
void readDormitory(vector<Dormitory>& d) {
|
|
|
|
|
|
|
|
d.clear();
|
|
|
|
|
|
|
|
ifstream ifs;
|
|
|
|
|
|
|
|
ifs.open("Dormitory.txt", ios::in);
|
|
|
|
|
|
|
|
int f = 0;//楼层总数临时变量
|
|
|
|
|
|
|
|
int r = 0;//每层房间数临时变量
|
|
|
|
|
|
|
|
int n = 0;//楼栋号临时变量
|
|
|
|
|
|
|
|
while (ifs >> n && ifs >> f && ifs >> r) {
|
|
|
|
|
|
|
|
Dormitory d1(f, r, n);//首先读入寝室楼的楼层数、每层房间数、楼栋号信息用以初始化一个寝室楼对象
|
|
|
|
|
|
|
|
string sn; //寝室号临时变量
|
|
|
|
|
|
|
|
string s1n; string s1i; string s1s;//第一个学生的姓名、学号、性别信息
|
|
|
|
|
|
|
|
string s2n; string s2i; string s2s;//第二个学
|
|
|
|
|
|
|
|
string s3n; string s3i; string s3s;//第三个学生
|
|
|
|
|
|
|
|
string s4n; string s4i; string s4s;//第四个学生
|
|
|
|
|
|
|
|
bool r;//是否报修
|
|
|
|
|
|
|
|
string bd;//报修内容临时变量
|
|
|
|
|
|
|
|
vector<Room>::iterator it = d1.room.begin();
|
|
|
|
|
|
|
|
while (ifs >> sn && ifs >> s1n && ifs >> s1s && ifs >> s1i && ifs >> s2n && ifs >> s2s && ifs >> s2i && ifs >> s3n && ifs >> s3s && ifs >> s3i && ifs >> s4n && ifs >> s4s && ifs >> s4i && ifs >> r&&ifs>>bd&& it != d1.room.end()) {
|
|
|
|
|
|
|
|
(*it).setRoom(sn, s1n, s1i, s1s, s2n, s2i, s2s, s3n, s3i, s3s, s4n, s4i, s4s, r,bd);
|
|
|
|
|
|
|
|
if (it != d1.room.end()-1) {
|
|
|
|
|
|
|
|
it++;
|
|
|
|
|
|
|
|
}//容器指针向后移动一位
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}//到达本容器最后一个存储位置,寝室信息读入停止
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
d.push_back(d1);//降本寝室楼压入容器
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ifs.close();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void addDormitory(vector<Dormitory>& d,int fl,int ro,int nu) {
|
|
|
|
|
|
|
|
Dormitory d1(fl, ro, nu);
|
|
|
|
|
|
|
|
d.push_back(d1);
|
|
|
|
|
|
|
|
saveDormitory(d);
|
|
|
|
|
|
|
|
readDormitory(d);
|
|
|
|
|
|
|
|
}//添加寝室楼函数
|
|
|
|
|
|
|
|
int judgeExitD(vector<Dormitory>& d, int nu) {
|
|
|
|
|
|
|
|
for (int i = 0; i < d.size(); i++) {
|
|
|
|
|
|
|
|
if (d[i].number == nu) {
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}//判断宿舍楼是否存在
|
|
|
|
|
|
|
|
string arrange(vector<Dormitory>& d,vector<Student>&s ,string na, string id, string se, int nu) {
|
|
|
|
|
|
|
|
string o;
|
|
|
|
|
|
|
|
for (int k = 0; k < s.size(); k++) {
|
|
|
|
|
|
|
|
if (s[k].name == na && s[k].studentID == id && s[k].sex == se) {
|
|
|
|
|
|
|
|
for (int i = 0; i < d.size(); i++) {
|
|
|
|
|
|
|
|
if (d[i].number == nu) {
|
|
|
|
|
|
|
|
int j = d[i].addStudent(s, na, id, se);
|
|
|
|
|
|
|
|
if (j == 1) {
|
|
|
|
|
|
|
|
o = o + na + "已排床成功!\n";
|
|
|
|
|
|
|
|
return o;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
o = o + na + "排床失败,本栋已无空余床位!\n";
|
|
|
|
|
|
|
|
return o;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
o = "该同学不存在,排床失败!\n";
|
|
|
|
|
|
|
|
return o;
|
|
|
|
|
|
|
|
}//安排单个同学床位,本函数尚未更新保存文件
|
|
|
|
|
|
|
|
string searchRoom(vector<Dormitory>& d, vector<Student>& s, string id) {
|
|
|
|
|
|
|
|
string o;
|
|
|
|
|
|
|
|
int k;
|
|
|
|
|
|
|
|
for (int i = 0; i < s.size(); i++) {
|
|
|
|
|
|
|
|
if (s[i].studentID == id) {
|
|
|
|
|
|
|
|
k = i;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}//判断该学生在学生容器中的位置
|
|
|
|
|
|
|
|
for (int i = 0; i < d.size(); i++) {
|
|
|
|
|
|
|
|
if (s[k].dormitoryNumber == d[i].number) {
|
|
|
|
|
|
|
|
for (int j = 0; j < d[i].room.size(); j++) {
|
|
|
|
|
|
|
|
if (d[i].room[j].stu[0].studentID == id || d[i].room[j].stu[1].studentID == id || d[i].room[j].stu[2].studentID == id || d[i].room[j].stu[3].studentID == id) {
|
|
|
|
|
|
|
|
string s = d[i].room[j].sendinfo();
|
|
|
|
|
|
|
|
return s;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}//查询该学生寝室号信息,返回该楼栋中该学生的寝室信息
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return o;//未查找到该信息,返回空字符串
|
|
|
|
|
|
|
|
}//查询单个寝室信息
|
|
|
|
|
|
|
|
int requestRepair(vector<Dormitory>& d, vector<Student>& s, string bd,string id) {
|
|
|
|
|
|
|
|
int k;
|
|
|
|
|
|
|
|
for (int i = 0; i < s.size(); i++) {
|
|
|
|
|
|
|
|
if (s[i].studentID == id) {
|
|
|
|
|
|
|
|
k = i;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}//判断该学生在学生容器中的位置
|
|
|
|
|
|
|
|
for (int i = 0; i < d.size(); i++) {
|
|
|
|
|
|
|
|
if (s[k].dormitoryNumber == d[i].number) {
|
|
|
|
|
|
|
|
for (int j = 0; j < d[i].room.size(); j++) {
|
|
|
|
|
|
|
|
if (d[i].room[j].stu[0].studentID == id || d[i].room[j].stu[1].studentID == id || d[i].room[j].stu[2].studentID == id || d[i].room[j].stu[3].studentID == id) {
|
|
|
|
|
|
|
|
d[i].room[j].repairReport = true;
|
|
|
|
|
|
|
|
d[i].room[j].breakdown = bd;
|
|
|
|
|
|
|
|
saveDormitory(d);
|
|
|
|
|
|
|
|
readDormitory(d);
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}//读取学生容器中该学生的寝室信息,在宿舍容器d中对该寝室的报修情况进行修改
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}//申请报修
|
|
|
|
|
|
|
|
string handleRepair(vector<Dormitory>& d, string num,int nu){
|
|
|
|
|
|
|
|
string o;
|
|
|
|
|
|
|
|
for (int i = 0; i < d[nu].room.size(); i++) {
|
|
|
|
|
|
|
|
if (d[nu].room[i].repairReport == true && d[nu].room[i].roomNumber == num) {
|
|
|
|
|
|
|
|
d[nu].room[i].repairReport = false;
|
|
|
|
|
|
|
|
d[nu].room[i].breakdown = "无";
|
|
|
|
|
|
|
|
o = num + "寝室报修情况已更新!\n";
|
|
|
|
|
|
|
|
saveDormitory(d);
|
|
|
|
|
|
|
|
readDormitory(d);
|
|
|
|
|
|
|
|
return o;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
o = "该寝室不存在或该寝室尚未报修!\n";
|
|
|
|
|
|
|
|
return o;
|
|
|
|
|
|
|
|
}//处理报修
|
|
|
|
|
|
|
|
int changeRoom1(vector<Dormitory>& d, vector<Student>& s, string na, string id, string rn,int nu) {
|
|
|
|
|
|
|
|
if (d[nu].judgeExitS(na, id) == 1) {
|
|
|
|
|
|
|
|
int k = -1;
|
|
|
|
|
|
|
|
for (int i = 0; i < d[nu].room.size(); i++) {
|
|
|
|
|
|
|
|
if (d[nu].room[i].roomNumber == rn) {
|
|
|
|
|
|
|
|
k = i;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}//确定该寝室在容器中的位置
|
|
|
|
|
|
|
|
if (k == -1) {
|
|
|
|
|
|
|
|
return 3;
|
|
|
|
|
|
|
|
}//该寝室不存在
|
|
|
|
|
|
|
|
if (d[nu].room[k].judgeEmpty() != 1) {
|
|
|
|
|
|
|
|
return 2;
|
|
|
|
|
|
|
|
}//目标寝室已满
|
|
|
|
|
|
|
|
string se;
|
|
|
|
|
|
|
|
int flag = 0;
|
|
|
|
|
|
|
|
for (int i = 0; i < d[nu].room.size(); i++) {
|
|
|
|
|
|
|
|
for (int j = 0; j < 4; j++) {
|
|
|
|
|
|
|
|
if (d[nu].room[i].stu[j].name == na && d[nu].room[i].stu[j].studentID == id) {
|
|
|
|
|
|
|
|
se = d[nu].room[i].stu[j].sex;
|
|
|
|
|
|
|
|
d[nu].room[i].stu[j].name = "未入住";
|
|
|
|
|
|
|
|
d[nu].room[i].stu[j].studentID = "不详";
|
|
|
|
|
|
|
|
d[nu].room[i].stu[j].sex = "不详";
|
|
|
|
|
|
|
|
flag = 1;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}//提取性别信息,将原寝室中该学生信息清空
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flag == 1) {
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < d[nu].room.size(); i++) {
|
|
|
|
|
|
|
|
if (d[nu].room[i].roomNumber == rn) {
|
|
|
|
|
|
|
|
int j;
|
|
|
|
|
|
|
|
for (j = 0; j < 4; j++) {
|
|
|
|
|
|
|
|
if (d[nu].room[i].stu[j].name == "未入住") {
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
d[nu].room[i].stu[j].name = na;
|
|
|
|
|
|
|
|
d[nu].room[i].stu[j].studentID = id;
|
|
|
|
|
|
|
|
d[nu].room[i].stu[j].sex = se;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}//在目标寝室中选中未入住的床位将信息填入
|
|
|
|
|
|
|
|
for (int i = 0; i < s.size(); i++) {
|
|
|
|
|
|
|
|
if (s[i].studentID == id) {
|
|
|
|
|
|
|
|
s[i].roomNumber = stoi(rn.c_str());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
saveDormitory(d);
|
|
|
|
|
|
|
|
saveStudent(s);
|
|
|
|
|
|
|
|
readDormitory(d);
|
|
|
|
|
|
|
|
readStudent(s);
|
|
|
|
|
|
|
|
return 1;//调整成功
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;//该该学生不存在
|
|
|
|
|
|
|
|
}//将学生调至有空床的宿舍时
|
|
|
|
|
|
|
|
int changeRoom2(vector<Dormitory>& d, vector<Student>& s, string na1, string id1, string na2, string id2, int nu) {
|
|
|
|
|
|
|
|
if (d[nu].judgeExitS(na1, id1) == 1 && d[nu].judgeExitS(na2, id2) == 1) {
|
|
|
|
|
|
|
|
int flag = 0;
|
|
|
|
|
|
|
|
int ro1, ro2;//房间容器位置临时变量
|
|
|
|
|
|
|
|
int st1, st2;//床位号临时变量
|
|
|
|
|
|
|
|
string rn1, rn2;//寝室号临时变量
|
|
|
|
|
|
|
|
for (int i = 0; i < d[nu].room.size(); i++) {
|
|
|
|
|
|
|
|
for (int j = 0; j < 4; j++) {
|
|
|
|
|
|
|
|
if (d[nu].room[i].stu[j].name == na1 && d[nu].room[i].stu[j].studentID == id1) {
|
|
|
|
|
|
|
|
ro1 = i;
|
|
|
|
|
|
|
|
st1 = j;
|
|
|
|
|
|
|
|
rn1 = d[nu].room[i].roomNumber;
|
|
|
|
|
|
|
|
flag = 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flag == 1) {
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}//确定学生1在寝室容器中的位置
|
|
|
|
|
|
|
|
flag = 0;
|
|
|
|
|
|
|
|
for (int i = 0; i < d[nu].room.size(); i++) {
|
|
|
|
|
|
|
|
for (int j = 0; j < 4; j++) {
|
|
|
|
|
|
|
|
if (d[nu].room[i].stu[j].name == na2 && d[nu].room[i].stu[j].studentID == id2) {
|
|
|
|
|
|
|
|
ro2 = i;
|
|
|
|
|
|
|
|
st2 = j;
|
|
|
|
|
|
|
|
rn2 = d[nu].room[i].roomNumber;
|
|
|
|
|
|
|
|
flag = 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flag == 1) {
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}//确定学生2在寝室容器中的位置
|
|
|
|
|
|
|
|
d[nu].room[ro1].stu[st1].name = na2;
|
|
|
|
|
|
|
|
d[nu].room[ro1].stu[st1].studentID = id2;
|
|
|
|
|
|
|
|
d[nu].room[ro2].stu[st2].name = na1;
|
|
|
|
|
|
|
|
d[nu].room[ro2].stu[st2].studentID = id1;//更新容器信息
|
|
|
|
|
|
|
|
for (int i = 0; i < s.size(); i++) {
|
|
|
|
|
|
|
|
if (s[i].studentID == id1) {
|
|
|
|
|
|
|
|
s[i].roomNumber = stoi(rn2.c_str());
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < s.size(); i++) {
|
|
|
|
|
|
|
|
if (s[i].studentID == id2) {
|
|
|
|
|
|
|
|
s[i].roomNumber = stoi(rn1.c_str());
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
saveDormitory(d);
|
|
|
|
|
|
|
|
saveStudent(s);
|
|
|
|
|
|
|
|
readDormitory(d);
|
|
|
|
|
|
|
|
readStudent(s);//更新文件存储
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;//有学生信息不存在
|
|
|
|
|
|
|
|
}//对两位同学进行宿舍对换,由于居住于同一栋宿舍故性别必然相同,仅需调换姓名及学号信息即可
|
|
|
|
|
|
|
|
int changeRepair(vector<Dormitory>& d, string rn, int nu) {
|
|
|
|
|
|
|
|
for (int i = 0; i < d[nu].room.size(); i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (d[nu].room[i].roomNumber == rn) {
|
|
|
|
|
|
|
|
d[nu].room[i].repairReport = false;
|
|
|
|
|
|
|
|
d[nu].room[i].breakdown = "无";
|
|
|
|
|
|
|
|
saveDormitory(d);
|
|
|
|
|
|
|
|
readDormitory(d);
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}//没用到,忘记写了这个函数了
|
|
|
|
|