共计 38218 个字符,预计需要花费 96 分钟才能阅读完成。
一、性能形容
本我的项目为“酒店客房管理系统”,实现了对酒店的客房信息进行治理,次要性能包含:
- 酒店初始化
(1) 初始化管理员账号密码
(2) 初始化操作员账号密码
(3) 初始化酒店客房信息
- 管理员治理
(1) 管理员登录
(2) 查看、减少、删除、批改操作员信息
(3) 操作员信息写入文件
(4) 查看、批改酒店客房信息
(5) 酒店客房信息写入文件
- 操作员治理
(1) 查看客房信息
(2) 客房的预订
(3) 客房的入住
(4) 客房的退房
(5) 预订查问(依据房号和姓名查问预订信息)
(6) 客房查问(依据房号查问房间信息)
(7) 住客查问(依据姓名查问住客信息)
(8) 操作员工作日志写入文件
二、设计与实现
1. 模块结构图及各模块的性能
模块结构图如下:
本酒店客房管理系统有两个模块:管理员模块和操作员模块。
管理员模块 的性能有:
- 管理员登录:依据输出账号密码登录进入管理员权限
-
操作员治理
- 查看操作员信息
- 减少操作员信息
- 删除操作员信息
- 批改操作员信息
-
酒店客房治理
- 查看酒店客房信息
- 批改酒店客房信息
操作员模块 的性能有:
- 操作员登录:依据输出账号密码登录进入操作员权限
- 查看客房信息
- 客房的预订
- 客房的入住
- 客房的退房
- 预订查问:依据房号和姓名查问预订信息
- 客房查问:依据房号查问房间信息
- 住客查问:依据姓名查问住客信息
2. 数据类型的设计和阐明
函数调用关系
Room 类
Room 类的数据类型如下:
在本我的项目的设计中,Room 是酒店客房的形象,而 Room 数组是酒店的形象。
友元函数 RoomInit:进行酒店房间初始化。本我的项目初始化了 20 间客房的类型和价格,并将酒店客房信息保留在 “酒店房间信息.xls” 文件中。
Operator 类
在本我的项目中,Operator 是酒店操作员的形象,并用一个 Operator 数组保留操作员信息。
友元函数 OperatorInit():进行操作员信息的初始化。本我的项目初始化了 10 位操作员的账号和明码,并将酒店客房信息保留在 “操作员账户信息.txt” 文件中。
友元函数 OperatorLogin():登录操作员账号。该函数传入 Operator 数组并返回登录操作员在数组的第几个元素。
成员函数 WriteRoomInformation(Room*):将 Room 数组中的信息写入到 “酒店房间信息.xls” 文件中。该函数是一个辅助函数,当 Room 数组的信息进行批改时,将调用该函数批改文件相应内容。
实现操作员相应性能的成员函数如下:
- ViewRoomInformation(Room*):查看酒店客房的根本信息。该信息不包含住客的根本信息。
- ReserveRoom(Room*):预订客房。该函数打印闲暇房间让用户抉择、并输出用户的姓名、身份证号、联系方式等根本信息。
- CheckIn(Room*):入住房间。该函数先询问客户是否预订房间,若预订需比照信息能力入住,若未预订则打印闲暇房间并输出个人信息实现入住。
- CheckOut(Room*):住客退房。该函数输出退房的房号并比对住客信息,如统一方可退房、将该房间的信息置空。
- RoomQuery(Room*):客房查问。输出查问房号可打印房间信息。
- BookQuery(Room*):预订查问。输出预订房号和姓名可查问预订信息。
- GuestQuery(Room*):住客查问。输出客户姓名可查问客户信息。
- OperatorQuit():操作员退出登录。返回主登录菜单或退出程序时将调用该函数。
以上操作员的所有操作均会保留在 “操作员工作日志.xls” 文件中。工作日志的工夫由以后零碎工夫取得。
Administrator 类
在本我的项目中,Administrator 是酒店管理员的形象。
构造函数 Administrator():初始化管理员账号和明码。在本我的项目中,管理员账号和明码被初始化后不可在程序中进行批改。
友元函数 OperatorLogin():登录管理员账号。该函数比对输出账号密码与管理员账号密码是否统一。
成员函数 WriteOperatorInformation(Operator*):将 Operator 数组中的信息写入到 “操作员账户信息.txt” 文件中。该函数是一个辅助函数,当 Operator 数组的信息进行批改时,将调用该函数批改文件相应内容。
实现管理员相应性能的成员函数如下:
- ViewOperatorInformation(Operator*):查看所有操作员的账号、明码。
- AddOperatorInformation(Operator*):减少操作员信息。
- DeleteOperatorInformation(Operator*):删除操作员信息。
- ModifyOperatorInformation(Operator*):批改操作员信息。
- ViewRoomInformation(Room*):查看酒店所有客房的类型与价格。
- ModifyRoomInformation(Room*):批改酒店客房数量、类型和价格。批改后将酒店客房信息写入 “酒店房间信息.xls” 文件中。
3. 要害性能的实现
主函数
main 函数流程图如下:
主函数中共有 3 个菜单界面:登录菜单界面、管理员菜单界面和操作员菜单界面。
登录菜单界面如下:
管理员菜单界面如下:
操作员菜单界面如下:
批改操作员信息
批改操作员信息的性能通过 Administrator::ModifyOperatorInformation 函数实现。
流程图如下:
实现源代码如下:
void Administrator::ModifyOperatorInformation(Operator* operators) | |
{ViewOperatorInformation(operators); | |
int choose; | |
string UserName_,Password_; | |
cout<<"\t\t# 请抉择要批改的操作员信息的序号:"; | |
cin>>choose; | |
int num = choose; | |
for(int x=0;x<=choose;x++){if(operators[x].UserName==""){num++;} | |
} | |
if(operators[num-1].UserName==""){ | |
cout<<"\t\t# 批改失败!该操作员不存在!"<<endl; | |
system("pause"); | |
return; | |
} | |
cout<<"\t\t# 请输出批改操作员账号:"; | |
cin>>UserName_; operators[num-1].UserName=UserName_; | |
cout<<"\t\t# 请输出批改操作员明码:"; | |
cin>>Password_; operators[num-1].Password=Password_; | |
WriteOperatorInformation(operators); | |
} |
测试界面如下:
批改酒店客房信息
批改酒店客房信息的性能通过 Administrator::ModifyRoomInformation 函数实现。
流程图如下:
实现源代码如下:
void Administrator::ModifyRoomInformation(Room* room) | |
{ | |
int StandardRoomNum, StandardRoomPrice; | |
int DoubleRoomNum, DoubleRoomPrice; | |
int SuiteRoomNum, SuiteRoomPrice; | |
cout<<"\t\t# 因为本酒店客房无限,请确保输出房间总数≤20。"<<endl<<endl; | |
cout<<"\t\t# 请输出标间个数:"; cin>>StandardRoomNum; | |
cout<<"\t\t# 请输出标间价格:"; cin>>StandardRoomPrice; | |
cout<<endl; | |
cout<<"\t\t# 请输出双人间个数:"; cin>>DoubleRoomNum; | |
cout<<"\t\t# 请输出双人间价格:"; cin>>DoubleRoomPrice; | |
cout<<endl; | |
cout<<"\t\t# 请输出套房个数:"; cin>>SuiteRoomNum; | |
cout<<"\t\t# 请输出套房价格:"; cin>>SuiteRoomPrice; | |
cout<<endl; | |
if(StandardRoomNum+DoubleRoomNum+SuiteRoomNum>20){ | |
cout<<"\t\t# 批改失败!您输出的房间个数超出本酒店的房间下限!请保障房间总数≤20!"<<endl; | |
system("pause"); | |
return; | |
} | |
int i[3]={1,0,1},k; | |
for(k=0; k<20; k++) | |
{room[k].RoomNum = 0; | |
room[k].RoomType = "NULL"; | |
room[k].RoomPrice = 0; | |
room[k].IsBooked = false; | |
room[k].IsChecked = false; | |
room[k].GuestName = "NULL"; | |
room[k].GuestID = "NULL"; | |
room[k].GuestTel = "NULL"; | |
room[k].CheckInTime = "NULL"; | |
room[k].BookTime = "NULL"; | |
} | |
for(k=0; k<(StandardRoomNum+DoubleRoomNum+SuiteRoomNum); k++) | |
{room[k].RoomNum=i[0]*100+i[1]*10+i[2]; | |
switch(i[0]) | |
{case 1:{room[k].RoomPrice=StandardRoomPrice; room[k].RoomType="标间";break;} | |
case 2:{room[k].RoomPrice=DoubleRoomPrice; room[k].RoomType="双人间";break;} | |
case 3:{room[k].RoomPrice=SuiteRoomPrice; room[k].RoomType="套房";break;} | |
} | |
if(k==(StandardRoomNum-1) ) | |
i[0]++,i[2]=0; | |
if(k==(DoubleRoomNum+StandardRoomNum-1) ) | |
i[0]++,i[2]=0; | |
i[2]++; | |
} | |
fstream read("酒店房间信息.xls",ios::out); | |
read<<"房间号 \t 类型 \t 价格 \t 是否预订 \t 是否入住 \t 姓名 \t 身份证号 \t 联系方式 \t 预订工夫 \t 入住工夫"<<endl; | |
for(int x=0;x<StandardRoomNum+DoubleRoomNum+SuiteRoomNum;x++) | |
{read<<room[x].RoomNum<<"\t"<<room[x].RoomType<<"\t"<<room[x].RoomPrice<<"\t"<<room[x].IsBooked<<"\t"<<room[x].IsChecked<<"\t"<<room[x].GuestName | |
<<"\t"<<room[x].GuestID<<"\t"<<room[x].GuestTel<<"\t"<<room[x].BookTime<<"\t"<<room[x].CheckInTime<<endl; | |
} | |
read.close(); | |
cout<<"\t\t# 批改胜利!"<<endl; | |
system("pause"); | |
return; | |
} |
测试界面如下:
酒店客房预订
酒店客房预订的性能通过 Operator::ReserveRoom 函数实现。
流程图如下:
实现源代码如下:
void Operator::ReserveRoom(Room* room) | |
{ | |
int RoomNum_, x; | |
cout<<"\t\t 可预订房间如下:"<<endl; | |
cout<<"\t ###########################"<<endl; | |
cout<<"\t\t 房间号 \t 类型 \t 价格"<<endl; | |
for(x=0;x<20;x++){if(room[x].RoomNum!=0 && room[x].IsBooked==false && room[x].IsChecked==false){cout<<"\t\t"<<room[x].RoomNum<<"\t"<<room[x].RoomType<<"\t"<<room[x].RoomPrice<<endl; | |
} | |
} | |
cout<<"\t ###########################"<<endl; | |
cout<<"\t\t# 请抉择要预订房间:"; cin>>RoomNum_; | |
for(x=0;x<20;x++){if(room[x].RoomNum==RoomNum_){if(room[x].IsBooked==false && room[x].IsChecked==false) break; | |
else { | |
cout<<"\t\t# 预订失败!您抉择的房间已被预订!"<<endl; | |
system("pause"); | |
return; | |
} | |
} | |
if(x==19){ | |
cout<<"\t\t# 预订失败!您抉择的房间已被预订!"<<endl; | |
system("pause"); | |
return; | |
} | |
} | |
cout<<"\t\t# 请输入您的个人信息:"<<endl; | |
cout<<"\t\t# 姓名:"; cin>>room[x].GuestName; | |
cout<<"\t\t# 身份证号:"; cin>>room[x].GuestID; | |
cout<<"\t\t# 联系方式:"; cin>>room[x].GuestTel; | |
time_t BookTime_; | |
time(&BookTime_); | |
room[x].BookTime = ctime(&BookTime_); | |
room[x].BookTime = room[x].BookTime.substr(0, room[x].BookTime.length() - 1); | |
room[x].IsBooked = true; | |
fstream file("操作员工作日志.xls",ios::app); | |
file<<UserName<<"\t"<<room[x].BookTime<<"\t 预订房间 \t"<<room[x].GuestName<<"\t"<<room[x].RoomNum<<endl; | |
file.close(); | |
WriteRoomInformation(room); | |
system("cls"); | |
cout<<"\t\t# 预订胜利!以下是您的预订信息:"<<endl; | |
cout<<"\t\t#################################################"<<endl; | |
cout<<"\t\t#\t\t@曾氏酒店客房管理系统 @"<<endl; | |
cout<<"\t\t#"<<endl; | |
cout<<"\t\t#\t 姓 名:"<<room[x].GuestName<<endl; | |
cout<<"\t\t#\t 身份证号:"<<room[x].GuestID<<endl; | |
cout<<"\t\t#\t 联系方式:"<<room[x].GuestTel<<endl; | |
cout<<"\t\t#\t 预订房号:"<<room[x].RoomNum<<endl; | |
cout<<"\t\t#\t 预订工夫:"<<room[x].BookTime<<endl; | |
cout<<"\t\t#"<<endl; | |
cout<<"\t\t#################################################"<<endl; | |
system("pause"); | |
} |
测试界面如下:
酒店客房入住
酒店客房入住的性能通过 Operator::CheckIn 函数实现。
流程图如下:
实现源代码如下:
void Operator::CheckIn(Room* room) | |
{ | |
char choose; | |
int RoomNum_, x; | |
string GuestName_, GuestID_; | |
cout<<"\t\t# 您是否已预订了房间?(Y/N):"; | |
cin>>choose; | |
if(choose=='N'||choose=='n') | |
{ | |
cout<<"\t\t# 可入住房间如下:"<<endl; | |
cout<<"\t ###########################"<<endl; | |
cout<<"\t\t 房间号 \t 类型 \t 价格"<<endl; | |
for(int x=0;x<20;x++){if(room[x].RoomNum!=0 && room[x].IsBooked==false && room[x].IsChecked==false){cout<<"\t\t"<<room[x].RoomNum<<"\t"<<room[x].RoomType<<"\t"<<room[x].RoomPrice<<endl; | |
} | |
} | |
cout<<"\t ###########################"<<endl; | |
cout<<"\t\t# 请抉择要入住房间:"; cin>>RoomNum_; | |
int x; | |
for(x=0;x<20;x++){if(room[x].RoomNum==RoomNum_){if(room[x].IsBooked==false && room[x].IsChecked==false) break; | |
else { | |
cout<<"\t\t# 入住失败!您抉择的房间已被预订!"<<endl; | |
system("pause"); | |
return; | |
} | |
} | |
if(x==19){ | |
cout<<"\t\t# 入住失败!您抉择的房间已被预订!"<<endl; | |
system("pause"); | |
return; | |
} | |
} | |
cout<<"\t\t# 请输入您的个人信息:"<<endl; | |
cout<<"\t\t# 姓名:"; cin>>room[x].GuestName; | |
cout<<"\t\t# 身份证号:"; cin>>room[x].GuestID; | |
cout<<"\t\t# 联系方式:"; cin>>room[x].GuestTel; | |
time_t CheckTime_; | |
time(&CheckTime_); | |
room[x].CheckInTime = ctime(&CheckTime_); | |
room[x].CheckInTime = room[x].CheckInTime.substr(0, room[x].CheckInTime.length() - 1); | |
room[x].IsChecked = true; | |
fstream file("操作员工作日志.xls",ios::app); | |
file<<UserName<<"\t"<<room[x].CheckInTime<<"\t 入住房间 \t"<<room[x].GuestName<<"\t"<<room[x].RoomNum<<endl; | |
file.close(); | |
WriteRoomInformation(room); | |
system("cls"); | |
cout<<"\t\t# 入住胜利!以下是您的入住信息:"<<endl; | |
cout<<"\t\t#################################################"<<endl; | |
cout<<"\t\t#\t\t@曾氏酒店客房管理系统 @"<<endl; | |
cout<<"\t\t#"<<endl; | |
cout<<"\t\t#\t 姓 名:"<<room[x].GuestName<<endl; | |
cout<<"\t\t#\t 身份证号:"<<room[x].GuestID<<endl; | |
cout<<"\t\t#\t 联系方式:"<<room[x].GuestTel<<endl; | |
cout<<"\t\t#\t 入住房号:"<<room[x].RoomNum<<endl; | |
cout<<"\t\t#\t 入住工夫:"<<room[x].CheckInTime<<endl; | |
cout<<"\t\t#"<<endl; | |
cout<<"\t\t#################################################"<<endl; | |
system("pause"); | |
} | |
else if(choose=='Y'||choose=='y') | |
{ | |
cout<<"\t\t# 请输入您预订的房号:"; cin>>RoomNum_; | |
for(x=0;x<20;x++){if(room[x].RoomNum==RoomNum_){if(room[x].IsBooked==false){ | |
cout<<"\t\t# 入住失败!您抉择的房间未被预订!"<<endl; | |
system("pause"); | |
return; | |
} | |
else if(room[x].IsChecked==true){ | |
cout<<"\t\t# 入住失败!您抉择的房间已入住!"<<endl; | |
system("pause"); | |
return; | |
} | |
else break; | |
} | |
if(x==19){ | |
cout<<"\t\t# 入住失败!您抉择的房间不存在!"<<endl; | |
system("pause"); | |
return; | |
} | |
} | |
cout<<"\t\t# 请输入您预订的个人信息:"<<endl; | |
cout<<"\t\t# 姓名:"; cin>>GuestName_; | |
cout<<"\t\t# 身份证号:"; cin>>GuestID_; | |
if(room[x].GuestName!=GuestName_ || room[x].GuestID!=GuestID_){ | |
cout<<"\t\t# 入住失败!您输出的信息不匹配!"<<endl; | |
system("pause"); | |
return; | |
} | |
time_t CheckTime_; | |
time(&CheckTime_); | |
room[x].CheckInTime = ctime(&CheckTime_); | |
room[x].CheckInTime = room[x].CheckInTime.substr(0, room[x].CheckInTime.length() - 1); | |
room[x].IsChecked = true; | |
fstream file("操作员工作日志.xls",ios::app); | |
file<<UserName<<"\t"<<room[x].CheckInTime<<"\t 入住房间 \t"<<room[x].GuestName<<"\t"<<room[x].RoomNum<<endl; | |
file.close(); | |
WriteRoomInformation(room); | |
system("cls"); | |
cout<<"\t\t# 入住胜利!以下是您的入住信息:"<<endl; | |
cout<<"\t\t#################################################"<<endl; | |
cout<<"\t\t#\t\t@曾氏酒店客房管理系统 @"<<endl; | |
cout<<"\t\t#"<<endl; | |
cout<<"\t\t#\t 姓 名:"<<room[x].GuestName<<endl; | |
cout<<"\t\t#\t 身份证号:"<<room[x].GuestID<<endl; | |
cout<<"\t\t#\t 联系方式:"<<room[x].GuestTel<<endl; | |
cout<<"\t\t#\t 入住房号:"<<room[x].RoomNum<<endl; | |
cout<<"\t\t#\t 入住工夫:"<<room[x].CheckInTime<<endl; | |
cout<<"\t\t#"<<endl; | |
cout<<"\t\t#################################################"<<endl; | |
system("pause"); | |
} | |
else | |
{cout<<"\t\t# 输出谬误!请输出(Y/N)!"<<endl; | |
system("pause"); | |
} | |
} |
测试界面如下:
酒店客房退房
酒店客房退房的性能通过 Operator::CheckOut 函数实现。
流程图如下:
实现源代码如下:
void Operator::CheckOut(Room* room) | |
{ | |
int RoomNum_, x; | |
cout<<"\t\t# 请输入您退房的房号:"; cin>>RoomNum_; | |
for(x=0;x<20;x++){if(room[x].RoomNum==RoomNum_){if(room[x].IsChecked==false){ | |
cout<<"\t\t# 退房失败!您抉择的房间未入住!"<<endl; | |
system("pause"); | |
return; | |
} | |
else break; | |
} | |
if(x==19){ | |
cout<<"\t\t# 退房失败!您抉择的房间不存在!"<<endl; | |
system("pause"); | |
return; | |
} | |
} | |
string GuestName_,GuestID_; | |
cout<<"\t\t# 请输入您的个人信息:"<<endl; | |
cout<<"\t\t# 姓名:"; cin>>GuestName_; | |
cout<<"\t\t# 身份证号:"; cin>>GuestID_; | |
if(room[x].GuestName!=GuestName_ || room[x].GuestID!=GuestID_){ | |
cout<<"\t\t# 退房失败!您输出的信息不匹配!"<<endl; | |
system("pause"); | |
return; | |
} | |
time_t CheckOutTime_; | |
string CheckOutTime; | |
time(&CheckOutTime_); | |
CheckOutTime = ctime(&CheckOutTime_); | |
CheckOutTime = CheckOutTime.substr(0, CheckOutTime.length() - 1); | |
room[x].IsBooked = false; | |
room[x].IsChecked = false; | |
fstream file("操作员工作日志.xls",ios::app); | |
file<<UserName<<"\t"<<CheckOutTime<<"\t 住客退房 \t"<<room[x].GuestName<<"\t"<<room[x].RoomNum<<endl; | |
file.close(); | |
room[x].GuestName = "NULL"; | |
room[x].GuestID = "NULL"; | |
room[x].GuestTel = "NULL"; | |
room[x].BookTime = "NULL"; | |
room[x].CheckInTime = "NULL"; | |
WriteRoomInformation(room); | |
cout<<"\t\t# 退房胜利!"<<endl; | |
system("pause"); | |
return; | |
} |
测试界面如下:
三、课程设计总结
Pains
在设计本零碎的过程中,我破费了很多工夫和心理让该程序对用户更敌对,致力设计使得程序更方便使用。在调试过程中我也遇到不少异样,包含因为编译器编码语言导致的程序运行异样,我查问多篇文章后将所有异样解决,最终实现了本课程设计。
在编写本设计报告的过程中,发现自己的程序中,结构化设计等方面仍有有余,对于理论问题的解决还能够进一步改良(如减少金额结算性能等)。在后续的程序设计中,我会对本我的项目进行欠缺,达到更优。
本程序设计破费了我不少心理,然而苦中有乐,我在编写程序的过程中取得了乐趣与满足感,也进一步加深了本人对于程序设计的思考,有很大播种。
Gains
通过本零碎的设计,我进步了剖析和解决理论问题的能力,坚固所学 C ++ 的常识,增强对结构化程序设计的思维。我全面系统地学习了面向对象程序设计的基本概念、根本语法和编程办法,独立实现了有肯定工作量的程序设计工作,强调好的程序设计格调。
附录:设计代码
include
Room.h
#ifndef ROOM_H | |
#define ROOM_H | |
#include <time.h> | |
#include<string> | |
#include <string.h> | |
#include<fstream> | |
using namespace std; | |
class Room | |
{ | |
public: | |
Room(); | |
Room(int RoomNum_,string RoomType_,int RoomPrice_,bool IsBooked_,bool IsChecked_); | |
friend void RoomInit(Room* room); | |
friend class Administrator; | |
friend class Operator; | |
private: | |
int RoomNum; | |
string RoomType; | |
int RoomPrice; | |
bool IsBooked; | |
bool IsChecked; | |
string GuestName; | |
string GuestID; | |
string GuestTel; | |
string BookTime; | |
string CheckInTime; | |
}; | |
#endif // ROOM_H |
Operator.h
#ifndef OPERATOR_H | |
#define OPERATOR_H | |
#include "Room.h" | |
#include<string> | |
#include <string.h> | |
#include<fstream> | |
#include <iostream> | |
#include <Windows.h> | |
using namespace std; | |
class Operator | |
{ | |
public: | |
Operator(); | |
string getUserName(){ return UserName;} | |
void ViewRoomInformation(Room*); | |
void WriteRoomInformation(Room*); | |
void ReserveRoom(Room*); | |
void CheckIn(Room*); | |
void CheckOut(Room*); | |
void RoomQuery(Room*); | |
void BookQuery(Room*); | |
void GuestQuery(Room*); | |
void OperatorQuit(); | |
friend void OperatorInit(Operator* operators); | |
friend int OperatorLogin(Operator* operators); | |
friend class Administrator; | |
private: | |
string UserName; | |
string Password; | |
}; | |
#endif // OPERATOR_H |
Administrator.h
#ifndef ADMINISTRATOR_H | |
#define ADMINISTRATOR_H | |
#include "Room.h" | |
#include "Operator.h" | |
#include <Windows.h> | |
class Administrator | |
{ | |
public: | |
Administrator(); | |
friend bool AdministratorLogin(Administrator); | |
void ViewOperatorInformation(Operator*); | |
void WriteOperatorInformation(Operator*); | |
void AddOperatorInformation(Operator*); | |
void DeleteOperatorInformation(Operator*); | |
void ModifyOperatorInformation(Operator*); | |
void ViewRoomInformation(Room*); | |
void ModifyRoomInformation(Room*); | |
private: | |
string UserName; | |
string Password; | |
}; | |
#endif // ADMINISTRATOR_H |
src
Room.cpp
#include "Room.h" | |
Room::Room() | |
{ | |
RoomNum = 0; | |
RoomType = "NULL"; | |
RoomPrice = 0; | |
IsBooked = false; | |
IsChecked = false; | |
GuestName = "NULL"; | |
GuestID = "NULL"; | |
GuestTel = "NULL"; | |
BookTime = "NULL"; | |
CheckInTime = "NULL"; | |
} | |
Room::Room(int RoomNum_,string RoomType_,int RoomPrice_,bool IsBooked_,bool IsChecked_) | |
{ | |
RoomNum = RoomNum_; | |
RoomType = RoomType_; | |
RoomPrice = RoomPrice_; | |
IsBooked = IsBooked_; | |
IsChecked = IsChecked_; | |
} | |
void RoomInit(Room* room) | |
{ | |
int StandardRoomNum = 8; | |
int DoubleRoomNum = 7; | |
int SuiteRoomNum = 20 - StandardRoomNum - DoubleRoomNum; | |
int i[3]={1,0,1},k; | |
for(k=0; k<20; k++) | |
{room[k].RoomNum=i[0]*100+i[1]*10+i[2]; | |
switch(i[0]) | |
{case 1:{room[k].RoomPrice=150; room[k].RoomType="标间";break;} | |
case 2:{room[k].RoomPrice=250; room[k].RoomType="双人间";break;} | |
case 3:{room[k].RoomPrice=500; room[k].RoomType="套房";break;} | |
} | |
if(k==(StandardRoomNum-1) ) | |
i[0]++,i[2]=0; | |
if(k==(DoubleRoomNum+StandardRoomNum-1) ) | |
i[0]++,i[2]=0; | |
i[2]++; | |
} | |
fstream read("酒店房间信息.xls",ios::out); | |
read<<"房间号 \t 类型 \t 价格 \t 是否预订 \t 是否入住 \t 姓名 \t 身份证号 \t 联系方式 \t 预订工夫 \t 入住工夫"<<endl; | |
for(int x=0;x<20;x++) | |
{read<<room[x].RoomNum<<"\t"<<room[x].RoomType<<"\t"<<room[x].RoomPrice<<"\t"<<room[x].IsBooked<<"\t"<<room[x].IsChecked<<"\t"<<room[x].GuestName | |
<<"\t"<<room[x].GuestID<<"\t"<<room[x].GuestTel<<"\t"<<room[x].BookTime<<"\t"<<room[x].CheckInTime<<endl; | |
} | |
read.close();} |
Operator.cpp
#include "Operator.h" | |
Operator::Operator() | |
{ | |
UserName = ""; | |
Password = ""; | |
} | |
void OperatorInit(Operator* operators) | |
{for(int k=0; k<10; k++) | |
{operators[k].UserName = "zeng" + to_string(k); | |
operators[k].Password = "000" + to_string(k); | |
} | |
fstream read("操作员账户信息.txt",ios::out); | |
read<<"账号 \t 明码"<<endl; | |
for(int x=0;x<10;x++) | |
{read<<operators[x].UserName<<"\t"<<operators[x].Password<<endl; | |
} | |
read.close(); | |
fstream file("操作员工作日志.xls",ios::out); | |
file<<"操作账号 \t 操作工夫 \t 操作内容 \t 操作对象 \t 操作房号"<<endl; | |
file.close();} | |
int OperatorLogin(Operator* operators) | |
{ | |
string UserName_,Password_; | |
cout<<"\t\t# 请输出操作员账号:"; | |
cin>>UserName_; | |
cout<<"\t\t# 请输出操作员明码:"; | |
cin>>Password_; | |
for(int i=0; i<20; i++) | |
{if( UserName_==operators[i].UserName && Password_==operators[i].Password ){ | |
time_t Time_; | |
string Time; | |
time(&Time_); | |
Time = ctime(&Time_); | |
Time = Time.substr(0, Time.length() - 1); | |
fstream file("操作员工作日志.xls",ios::app); | |
file<<operators[i].UserName<<"\t"<<Time<<"\t 操作员登录"<<endl; | |
file.close(); | |
return i; | |
} | |
} | |
return -1; | |
} | |
void Operator::OperatorQuit() | |
{ | |
cout<<"\t\t###################################"<<endl; | |
cout<<"\t\t# @曾氏酒店客房管理系统 @ #"<<endl; | |
cout<<"\t\t# #"<<endl; | |
cout<<"\t\t# 再见!#"<<endl; | |
cout<<"\t\t# designed by 曾诗琦 #"<<endl; | |
cout<<"\t\t# LZU 320180943570 #"<<endl; | |
cout<<"\t\t# #"<<endl; | |
cout<<"\t\t###################################"<<endl; | |
time_t Time_; | |
string Time; | |
time(&Time_); | |
Time = ctime(&Time_); | |
Time = Time.substr(0, Time.length() - 1); | |
fstream file("操作员工作日志.xls",ios::app); | |
file<<UserName<<"\t"<<Time<<"\t 操作员退出"<<endl; | |
file.close();} | |
void Operator::ViewRoomInformation(Room* room) | |
{ | |
int StandardRoomNum=0, DoubleRoomNum=0, SuiteRoomNum=0; | |
int StandardRoomPrice=0, DoubleRoomPrice=0, SuiteRoomPrice=0; | |
int StandardBookedNum=0, StandardCheckedNum=0; | |
int DoubleBookedNum=0, DoubleCheckedNum=0; | |
int SuiteBookedNum=0, SuiteCheckedNum=0; | |
cout<<setw(4)<<setfill('')<<" 房号 "<<setw(7)<<setfill(' ')<<" 类型 "<<setw(5)<<setfill(' ')<<" 价格 "<<setw(5)<<setfill(' ')<<" 预订 "<<setw(5)<<setfill(' ')<<" 入住 "; | |
cout<<setw(8)<<setfill('')<<" 姓名 "<<setw(19)<<setfill(' ')<<" 身份证号 "<<setw(12)<<setfill(' ')<<" 联系方式 "<<endl; | |
for(int x=0;x<20;x++){if(room[x].RoomNum!=0){if(room[x].RoomType=="标间"){StandardRoomPrice = room[x].RoomPrice; | |
StandardRoomNum++; | |
if(room[x].IsBooked) StandardBookedNum++; | |
if(room[x].IsChecked) StandardCheckedNum++; | |
} | |
if(room[x].RoomType=="双人间"){DoubleRoomPrice = room[x].RoomPrice; | |
DoubleRoomNum++; | |
if(room[x].IsBooked) DoubleBookedNum++; | |
if(room[x].IsChecked) DoubleCheckedNum++; | |
} | |
if(room[x].RoomType=="套房"){SuiteRoomPrice = room[x].RoomPrice; | |
SuiteRoomNum++; | |
if(room[x].IsBooked) SuiteBookedNum++; | |
if(room[x].IsChecked) SuiteCheckedNum++; | |
} | |
cout<<setw(4)<<setfill('')<<room[x].RoomNum<<setw(7)<<setfill(' ')<<room[x].RoomType<<setw(5)<<setfill(' ')<<room[x].RoomPrice; | |
if(room[x].IsBooked) cout<<setw(5)<<setfill('')<<" 是 "; else cout<<setw(5)<<setfill(' ')<<" 否 "; | |
if(room[x].IsChecked) cout<<setw(5)<<setfill('')<<" 是 "; else cout<<setw(5)<<setfill(' ')<<" 否 "; | |
cout<<setw(8)<<setfill('')<<room[x].GuestName<<setw(19)<<setfill(' ')<<room[x].GuestID<<setw(12)<<setfill(' ')<<room[x].GuestTel<<endl; | |
} | |
} | |
cout<<endl<<"##########################################"<<endl; | |
cout<<"#"<<endl; | |
cout<<"#\t\t# 酒店房间 #"<<endl; | |
cout<<"#\t 酒店房间共"<<StandardRoomNum+DoubleRoomNum+SuiteRoomNum<<"间"<<endl | |
<<"#\t 已预订"<<StandardBookedNum+DoubleBookedNum+SuiteBookedNum<<"间 \t 未预订"<<StandardRoomNum+DoubleRoomNum+SuiteRoomNum-(StandardBookedNum+DoubleBookedNum+SuiteBookedNum)<<"间"<<endl | |
<<"#\t 已入住"<<StandardCheckedNum+DoubleCheckedNum+SuiteCheckedNum<<"间 \t 未入住"<<StandardRoomNum+DoubleRoomNum+SuiteRoomNum-(StandardCheckedNum+DoubleCheckedNum+SuiteCheckedNum)<<"间"<<endl; | |
cout<<"#"<<endl; | |
cout<<"#\t\t# 标 间 #"<<endl; | |
cout<<"#\t 标间共"<<StandardRoomNum<<"间 \t 价格"<<StandardRoomPrice<<"元"<<endl | |
<<"#\t 已预订"<<StandardBookedNum<<"间 \t 未预订"<<StandardRoomNum-StandardBookedNum<<"间"<<endl | |
<<"#\t 已入住"<<StandardCheckedNum<<"间 \t 未入住"<<StandardRoomNum-StandardCheckedNum<<"间"<<endl; | |
cout<<"#"<<endl; | |
cout<<"#\t\t# 双人间 #"<<endl; | |
cout<<"#\t 双人间共"<<DoubleRoomNum<<"间 \t 价格"<<DoubleRoomPrice<<"元"<<endl | |
<<"#\t 已预订"<<DoubleBookedNum<<"间 \t 未预订"<<DoubleRoomNum-DoubleBookedNum<<"间"<<endl | |
<<"#\t 已入住"<<DoubleCheckedNum<<"间 \t 未入住"<<DoubleRoomNum-DoubleCheckedNum<<"间"<<endl; | |
cout<<"#"<<endl; | |
cout<<"#\t\t# 套 房 #"<<endl; | |
cout<<"#\t 套房共"<<SuiteRoomNum<<"间 \t 价格"<<SuiteRoomPrice<<"元"<<endl | |
<<"#\t 已预订"<<SuiteBookedNum<<"间 \t 未预订"<<SuiteRoomNum-SuiteBookedNum<<"间"<<endl | |
<<"#\t 已入住"<<SuiteCheckedNum<<"间 \t 未入住"<<SuiteRoomNum-SuiteCheckedNum<<"间"<<endl; | |
cout<<"#"<<endl; | |
cout<<"##########################################"<<endl; | |
time_t Time_; | |
string Time; | |
time(&Time_); | |
Time = ctime(&Time_); | |
Time = Time.substr(0, Time.length() - 1); | |
fstream file("操作员工作日志.xls",ios::app); | |
file<<UserName<<"\t"<<Time<<"\t 查看客房信息"<<endl; | |
file.close();} | |
void Operator::WriteRoomInformation(Room* room) | |
{fstream read("酒店房间信息.xls",ios::out); | |
read<<"房间号 \t 类型 \t 价格 \t 是否预订 \t 是否入住 \t 姓名 \t 身份证号 \t 联系方式 \t 预订工夫 \t 入住工夫"<<endl; | |
for(int x=0;x<20;x++) | |
{if(room[x].RoomNum!=0) | |
read<<room[x].RoomNum<<"\t"<<room[x].RoomType<<"\t"<<room[x].RoomPrice<<"\t"<<room[x].IsBooked<<"\t"<<room[x].IsChecked<<"\t"<<room[x].GuestName | |
<<"\t"<<room[x].GuestID<<"\t"<<room[x].GuestTel<<"\t"<<room[x].BookTime<<"\t"<<room[x].CheckInTime<<endl; | |
} | |
read.close();} | |
void Operator::ReserveRoom(Room* room) | |
{ | |
int RoomNum_, x; | |
cout<<"\t\t 可预订房间如下:"<<endl; | |
cout<<"\t ###########################"<<endl; | |
cout<<"\t\t 房间号 \t 类型 \t 价格"<<endl; | |
for(x=0;x<20;x++){if(room[x].RoomNum!=0 && room[x].IsBooked==false && room[x].IsChecked==false){cout<<"\t\t"<<room[x].RoomNum<<"\t"<<room[x].RoomType<<"\t"<<room[x].RoomPrice<<endl; | |
} | |
} | |
cout<<"\t ###########################"<<endl; | |
cout<<"\t\t# 请抉择要预订房间:"; cin>>RoomNum_; | |
for(x=0;x<20;x++){if(room[x].RoomNum==RoomNum_){if(room[x].IsBooked==false && room[x].IsChecked==false) break; | |
else { | |
cout<<"\t\t# 预订失败!您抉择的房间已被预订!"<<endl; | |
system("pause"); | |
return; | |
} | |
} | |
if(x==19){ | |
cout<<"\t\t# 预订失败!您抉择的房间已被预订!"<<endl; | |
system("pause"); | |
return; | |
} | |
} | |
cout<<"\t\t# 请输入您的个人信息:"<<endl; | |
cout<<"\t\t# 姓名:"; cin>>room[x].GuestName; | |
cout<<"\t\t# 身份证号:"; cin>>room[x].GuestID; | |
cout<<"\t\t# 联系方式:"; cin>>room[x].GuestTel; | |
time_t BookTime_; | |
time(&BookTime_); | |
room[x].BookTime = ctime(&BookTime_); | |
room[x].BookTime = room[x].BookTime.substr(0, room[x].BookTime.length() - 1); | |
room[x].IsBooked = true; | |
fstream file("操作员工作日志.xls",ios::app); | |
file<<UserName<<"\t"<<room[x].BookTime<<"\t 预订房间 \t"<<room[x].GuestName<<"\t"<<room[x].RoomNum<<endl; | |
file.close(); | |
WriteRoomInformation(room); | |
system("cls"); | |
cout<<"\t\t# 预订胜利!以下是您的预订信息:"<<endl; | |
cout<<"\t\t#################################################"<<endl; | |
cout<<"\t\t#\t\t@曾氏酒店客房管理系统 @"<<endl; | |
cout<<"\t\t#"<<endl; | |
cout<<"\t\t#\t 姓 名:"<<room[x].GuestName<<endl; | |
cout<<"\t\t#\t 身份证号:"<<room[x].GuestID<<endl; | |
cout<<"\t\t#\t 联系方式:"<<room[x].GuestTel<<endl; | |
cout<<"\t\t#\t 预订房号:"<<room[x].RoomNum<<endl; | |
cout<<"\t\t#\t 预订工夫:"<<room[x].BookTime<<endl; | |
cout<<"\t\t#"<<endl; | |
cout<<"\t\t#################################################"<<endl; | |
system("pause"); | |
} | |
void Operator::CheckIn(Room* room) | |
{ | |
char choose; | |
int RoomNum_, x; | |
string GuestName_, GuestID_; | |
cout<<"\t\t# 您是否已预订了房间?(Y/N):"; | |
cin>>choose; | |
if(choose=='N'||choose=='n') | |
{ | |
cout<<"\t\t# 可入住房间如下:"<<endl; | |
cout<<"\t ###########################"<<endl; | |
cout<<"\t\t 房间号 \t 类型 \t 价格"<<endl; | |
for(int x=0;x<20;x++){if(room[x].RoomNum!=0 && room[x].IsBooked==false && room[x].IsChecked==false){cout<<"\t\t"<<room[x].RoomNum<<"\t"<<room[x].RoomType<<"\t"<<room[x].RoomPrice<<endl; | |
} | |
} | |
cout<<"\t ###########################"<<endl; | |
cout<<"\t\t# 请抉择要入住房间:"; cin>>RoomNum_; | |
int x; | |
for(x=0;x<20;x++){if(room[x].RoomNum==RoomNum_){if(room[x].IsBooked==false && room[x].IsChecked==false) break; | |
else { | |
cout<<"\t\t# 入住失败!您抉择的房间已被预订!"<<endl; | |
system("pause"); | |
return; | |
} | |
} | |
if(x==19){ | |
cout<<"\t\t# 入住失败!您抉择的房间已被预订!"<<endl; | |
system("pause"); | |
return; | |
} | |
} | |
cout<<"\t\t# 请输入您的个人信息:"<<endl; | |
cout<<"\t\t# 姓名:"; cin>>room[x].GuestName; | |
cout<<"\t\t# 身份证号:"; cin>>room[x].GuestID; | |
cout<<"\t\t# 联系方式:"; cin>>room[x].GuestTel; | |
time_t CheckTime_; | |
time(&CheckTime_); | |
room[x].CheckInTime = ctime(&CheckTime_); | |
room[x].CheckInTime = room[x].CheckInTime.substr(0, room[x].CheckInTime.length() - 1); | |
room[x].IsChecked = true; | |
fstream file("操作员工作日志.xls",ios::app); | |
file<<UserName<<"\t"<<room[x].CheckInTime<<"\t 入住房间 \t"<<room[x].GuestName<<"\t"<<room[x].RoomNum<<endl; | |
file.close(); | |
WriteRoomInformation(room); | |
system("cls"); | |
cout<<"\t\t# 入住胜利!以下是您的入住信息:"<<endl; | |
cout<<"\t\t#################################################"<<endl; | |
cout<<"\t\t#\t\t@曾氏酒店客房管理系统 @"<<endl; | |
cout<<"\t\t#"<<endl; | |
cout<<"\t\t#\t 姓 名:"<<room[x].GuestName<<endl; | |
cout<<"\t\t#\t 身份证号:"<<room[x].GuestID<<endl; | |
cout<<"\t\t#\t 联系方式:"<<room[x].GuestTel<<endl; | |
cout<<"\t\t#\t 入住房号:"<<room[x].RoomNum<<endl; | |
cout<<"\t\t#\t 入住工夫:"<<room[x].CheckInTime<<endl; | |
cout<<"\t\t#"<<endl; | |
cout<<"\t\t#################################################"<<endl; | |
system("pause"); | |
} | |
else if(choose=='Y'||choose=='y') | |
{ | |
cout<<"\t\t# 请输入您预订的房号:"; cin>>RoomNum_; | |
for(x=0;x<20;x++){if(room[x].RoomNum==RoomNum_){if(room[x].IsBooked==false){ | |
cout<<"\t\t# 入住失败!您抉择的房间未被预订!"<<endl; | |
system("pause"); | |
return; | |
} | |
else if(room[x].IsChecked==true){ | |
cout<<"\t\t# 入住失败!您抉择的房间已入住!"<<endl; | |
system("pause"); | |
return; | |
} | |
else break; | |
} | |
if(x==19){ | |
cout<<"\t\t# 入住失败!您抉择的房间不存在!"<<endl; | |
system("pause"); | |
return; | |
} | |
} | |
cout<<"\t\t# 请输入您预订的个人信息:"<<endl; | |
cout<<"\t\t# 姓名:"; cin>>GuestName_; | |
cout<<"\t\t# 身份证号:"; cin>>GuestID_; | |
if(room[x].GuestName!=GuestName_ || room[x].GuestID!=GuestID_){ | |
cout<<"\t\t# 入住失败!您输出的信息不匹配!"<<endl; | |
system("pause"); | |
return; | |
} | |
time_t CheckTime_; | |
time(&CheckTime_); | |
room[x].CheckInTime = ctime(&CheckTime_); | |
room[x].CheckInTime = room[x].CheckInTime.substr(0, room[x].CheckInTime.length() - 1); | |
room[x].IsChecked = true; | |
fstream file("操作员工作日志.xls",ios::app); | |
file<<UserName<<"\t"<<room[x].CheckInTime<<"\t 入住房间 \t"<<room[x].GuestName<<"\t"<<room[x].RoomNum<<endl; | |
file.close(); | |
WriteRoomInformation(room); | |
system("cls"); | |
cout<<"\t\t# 入住胜利!以下是您的入住信息:"<<endl; | |
cout<<"\t\t#################################################"<<endl; | |
cout<<"\t\t#\t\t@曾氏酒店客房管理系统 @"<<endl; | |
cout<<"\t\t#"<<endl; | |
cout<<"\t\t#\t 姓 名:"<<room[x].GuestName<<endl; | |
cout<<"\t\t#\t 身份证号:"<<room[x].GuestID<<endl; | |
cout<<"\t\t#\t 联系方式:"<<room[x].GuestTel<<endl; | |
cout<<"\t\t#\t 入住房号:"<<room[x].RoomNum<<endl; | |
cout<<"\t\t#\t 入住工夫:"<<room[x].CheckInTime<<endl; | |
cout<<"\t\t#"<<endl; | |
cout<<"\t\t#################################################"<<endl; | |
system("pause"); | |
} | |
else | |
{cout<<"\t\t# 输出谬误!请输出(Y/N)!"<<endl; | |
system("pause"); | |
} | |
} | |
void Operator::CheckOut(Room* room) | |
{ | |
int RoomNum_, x; | |
cout<<"\t\t# 请输入您退房的房号:"; cin>>RoomNum_; | |
for(x=0;x<20;x++){if(room[x].RoomNum==RoomNum_){if(room[x].IsChecked==false){ | |
cout<<"\t\t# 退房失败!您抉择的房间未入住!"<<endl; | |
system("pause"); | |
return; | |
} | |
else break; | |
} | |
if(x==19){ | |
cout<<"\t\t# 退房失败!您抉择的房间不存在!"<<endl; | |
system("pause"); | |
return; | |
} | |
} | |
string GuestName_,GuestID_; | |
cout<<"\t\t# 请输入您的个人信息:"<<endl; | |
cout<<"\t\t# 姓名:"; cin>>GuestName_; | |
cout<<"\t\t# 身份证号:"; cin>>GuestID_; | |
if(room[x].GuestName!=GuestName_ || room[x].GuestID!=GuestID_){ | |
cout<<"\t\t# 退房失败!您输出的信息不匹配!"<<endl; | |
system("pause"); | |
return; | |
} | |
time_t CheckOutTime_; | |
string CheckOutTime; | |
time(&CheckOutTime_); | |
CheckOutTime = ctime(&CheckOutTime_); | |
CheckOutTime = CheckOutTime.substr(0, CheckOutTime.length() - 1); | |
room[x].IsBooked = false; | |
room[x].IsChecked = false; | |
fstream file("操作员工作日志.xls",ios::app); | |
file<<UserName<<"\t"<<CheckOutTime<<"\t 住客退房 \t"<<room[x].GuestName<<"\t"<<room[x].RoomNum<<endl; | |
file.close(); | |
room[x].GuestName = "NULL"; | |
room[x].GuestID = "NULL"; | |
room[x].GuestTel = "NULL"; | |
room[x].BookTime = "NULL"; | |
room[x].CheckInTime = "NULL"; | |
WriteRoomInformation(room); | |
cout<<"\t\t# 退房胜利!"<<endl; | |
system("pause"); | |
return; | |
} | |
void Operator::BookQuery(Room* room) | |
{ | |
int RoomNum_, x; | |
string GuestName_; | |
cout<<"\t\t# 请输入您预订的房号:"; cin>>RoomNum_; | |
cout<<"\t\t# 请输入您预订的姓名:"; cin>>GuestName_; | |
for(x=0;x<20;x++){if(room[x].RoomNum==RoomNum_){if(room[x].IsBooked==false){ | |
cout<<"\t\t# 查问失败!您抉择的房间未被预订!"<<endl; | |
system("pause"); | |
return; | |
} | |
else if(room[x].IsChecked==true){ | |
cout<<"\t\t# 查问失败!您抉择的房间已入住!"<<endl; | |
system("pause"); | |
return; | |
} | |
else if(room[x].GuestName!=GuestName_){ | |
cout<<"\t\t# 查问失败!您输出的信息不匹配!"<<endl; | |
system("pause"); | |
return; | |
} | |
else break; | |
} | |
if(x==19){ | |
cout<<"\t\t# 查问失败!您抉择的房间不存在!"<<endl; | |
system("pause"); | |
return; | |
} | |
} | |
system("cls"); | |
cout<<"\t\t# 查问胜利!以下是您的预订信息:"<<endl; | |
cout<<"\t\t#################################################"<<endl; | |
cout<<"\t\t#\t\t@曾氏酒店客房管理系统 @"<<endl; | |
cout<<"\t\t#"<<endl; | |
cout<<"\t\t#\t 姓 名:"<<room[x].GuestName<<endl; | |
cout<<"\t\t#\t 身份证号:"<<room[x].GuestID<<endl; | |
cout<<"\t\t#\t 联系方式:"<<room[x].GuestTel<<endl; | |
cout<<"\t\t#\t 预订房号:"<<room[x].RoomNum<<endl; | |
cout<<"\t\t#\t 预订工夫:"<<room[x].BookTime<<endl; | |
cout<<"\t\t#"<<endl; | |
cout<<"\t\t#################################################"<<endl; | |
system("pause"); | |
time_t Time_; | |
string Time; | |
time(&Time_); | |
Time = ctime(&Time_); | |
Time = Time.substr(0, Time.length() - 1); | |
fstream file("操作员工作日志.xls",ios::app); | |
file<<UserName<<"\t"<<Time<<"\t 预订查问"<<endl; | |
file.close();} | |
void Operator::RoomQuery(Room* room) | |
{ | |
int RoomNum_, x; | |
cout<<"\t\t# 请输入您查问的房号:"; cin>>RoomNum_; | |
for(x=0;x<20;x++){if(room[x].RoomNum==RoomNum_){break;} | |
if(x==19){ | |
cout<<"\t\t# 查问失败!您抉择的房间不存在!"<<endl; | |
system("pause"); | |
return; | |
} | |
} | |
system("cls"); | |
cout<<"\t\t# 查问胜利!以下是您的查问信息:"<<endl; | |
cout<<"\t\t#################################################"<<endl; | |
cout<<"\t\t#\t\t@曾氏酒店客房管理系统 @"<<endl; | |
cout<<"\t\t#"<<endl; | |
cout<<"\t\t#\t 房 间 号:"<<room[x].RoomNum<<endl; | |
cout<<"\t\t#\t 房间类型:"<<room[x].RoomType<<endl; | |
cout<<"\t\t#\t 房间价格:"<<room[x].RoomPrice<<endl; | |
cout<<"\t\t#\t 是否预订:"; if(room[x].IsBooked) cout<<"是"<<endl; else cout<<"否"<<endl; | |
cout<<"\t\t#\t 是否入住:"; if(room[x].IsChecked) cout<<"是"<<endl; else cout<<"否"<<endl; | |
if(room[x].IsChecked) | |
{cout<<"\t\t#\t 姓 名:"<<room[x].GuestName<<endl; | |
cout<<"\t\t#\t 身份证号:"<<room[x].GuestID<<endl; | |
cout<<"\t\t#\t 联系方式:"<<room[x].GuestTel<<endl; | |
cout<<"\t\t#\t 入住工夫:"<<room[x].CheckInTime<<endl; | |
} | |
else if(room[x].IsBooked) | |
{cout<<"\t\t#\t 姓 名:"<<room[x].GuestName<<endl; | |
cout<<"\t\t#\t 身份证号:"<<room[x].GuestID<<endl; | |
cout<<"\t\t#\t 联系方式:"<<room[x].GuestTel<<endl; | |
cout<<"\t\t#\t 预订工夫:"<<room[x].BookTime<<endl; | |
} | |
cout<<"\t\t#"<<endl; | |
cout<<"\t\t#################################################"<<endl; | |
system("pause"); | |
time_t Time_; | |
string Time; | |
time(&Time_); | |
Time = ctime(&Time_); | |
Time = Time.substr(0, Time.length() - 1); | |
fstream file("操作员工作日志.xls",ios::app); | |
file<<UserName<<"\t"<<Time<<"\t 客房查问"<<endl; | |
file.close();} | |
void Operator::GuestQuery(Room* room) | |
{ | |
int x; | |
string GuestName_; | |
cout<<"\t\t# 请输入您查问的客户姓名:"; cin>>GuestName_; | |
for(x=0;x<20;x++){if(room[x].GuestName==GuestName_){break;} | |
if(x==19){ | |
cout<<"\t\t# 查问失败!您查问的客户不存在!"<<endl; | |
system("pause"); | |
return; | |
} | |
} | |
system("cls"); | |
cout<<"\t\t# 查问胜利!以下是您的查问信息:"<<endl; | |
cout<<"\t\t#################################################"<<endl; | |
cout<<"\t\t#\t\t@曾氏酒店客房管理系统 @"<<endl; | |
cout<<"\t\t#"<<endl; | |
cout<<"\t\t#\t 姓 名:"<<room[x].GuestName<<endl; | |
cout<<"\t\t#\t 身份证号:"<<room[x].GuestID<<endl; | |
cout<<"\t\t#\t 联系方式:"<<room[x].GuestTel<<endl; | |
cout<<"\t\t#\t 是否预订:"; if(room[x].IsBooked) cout<<"是"<<endl; else cout<<"否"<<endl; | |
cout<<"\t\t#\t 是否入住:"; if(room[x].IsChecked) cout<<"是"<<endl; else cout<<"否"<<endl; | |
if(room[x].IsChecked) | |
{cout<<"\t\t#\t 入住房号:"<<room[x].RoomNum<<endl; | |
cout<<"\t\t#\t 房间类型:"<<room[x].RoomType<<endl; | |
cout<<"\t\t#\t 房间价格:"<<room[x].RoomPrice<<endl; | |
cout<<"\t\t#\t 入住工夫:"<<room[x].CheckInTime<<endl; | |
} | |
else if(room[x].IsBooked) | |
{cout<<"\t\t#\t 预订房号:"<<room[x].RoomNum<<endl; | |
cout<<"\t\t#\t 房间类型:"<<room[x].RoomType<<endl; | |
cout<<"\t\t#\t 房间价格:"<<room[x].RoomPrice<<endl; | |
cout<<"\t\t#\t 预订工夫:"<<room[x].BookTime<<endl; | |
} | |
cout<<"\t\t#"<<endl; | |
cout<<"\t\t#################################################"<<endl; | |
system("pause"); | |
time_t Time_; | |
string Time; | |
time(&Time_); | |
Time = ctime(&Time_); | |
Time = Time.substr(0, Time.length() - 1); | |
fstream file("操作员工作日志.xls",ios::app); | |
file<<UserName<<"\t"<<Time<<"\t 客户查问"<<endl; | |
file.close();} |
Administrator.cpp
#include "Administrator.h" | |
Administrator::Administrator() | |
{ | |
UserName = "zsq"; | |
Password = "000"; | |
} | |
bool AdministratorLogin(Administrator a) | |
{ | |
string UserName_,Password_; | |
cout<<"\t\t# 请输出管理员账号:"; | |
cin>>UserName_; | |
cout<<"\t\t# 请输出管理员明码:"; | |
cin>>Password_; | |
if(UserName_==a.UserName && Password_==a.Password) | |
return true; | |
else return false; | |
} | |
void Administrator::ViewOperatorInformation(Operator* operators) | |
{ | |
int num = 0; | |
cout<<"\t\t 序号 \t 账号 \t 明码"<<endl; | |
for(int x=0;x<20;x++){if(operators[x].UserName!=""){ | |
num++; | |
cout<<"\t\t"<<num<<": \t"<<operators[x].UserName<<"\t"<<operators[x].Password<<endl; | |
} | |
} | |
} | |
void Administrator::WriteOperatorInformation(Operator* operators) | |
{fstream read("操作员账户信息.txt",ios::out); | |
read<<"账号 \t 明码"<<endl; | |
for(int x=0;x<20;x++) | |
{if(operators[x].UserName!="") | |
read<<operators[x].UserName<<"\t"<<operators[x].Password<<endl; | |
} | |
read.close();} | |
void Administrator::AddOperatorInformation(Operator* operators) | |
{ | |
string UserName_,Password_; | |
for(int x=0;x<20;x++){if(operators[x].UserName==""){ | |
cout<<"\t\t# 请输出新增操作员账号:"; | |
cin>>UserName_; operators[x].UserName=UserName_; | |
cout<<"\t\t# 请输出新增操作员明码:"; | |
cin>>Password_; operators[x].Password=Password_; | |
WriteOperatorInformation(operators); | |
break; | |
} | |
} | |
} | |
void Administrator::DeleteOperatorInformation(Operator* operators) | |
{ViewOperatorInformation(operators); | |
int choose; | |
cout<<"\t\t# 请抉择要删除的操作员信息的序号:"; | |
cin>>choose; | |
int num = choose; | |
for(int x=0;x<choose;x++){if(operators[x].UserName==""){num++;} | |
} | |
if(operators[num-1].UserName==""){ | |
cout<<"\t\t# 删除失败!该操作员不存在!"<<endl; | |
system("pause"); | |
return; | |
} | |
operators[num-1].UserName=""; | |
operators[num-1].Password=""; | |
WriteOperatorInformation(operators); | |
} | |
void Administrator::ModifyOperatorInformation(Operator* operators) | |
{ViewOperatorInformation(operators); | |
int choose; | |
string UserName_,Password_; | |
cout<<"\t\t# 请抉择要批改的操作员信息的序号:"; | |
cin>>choose; | |
int num = choose; | |
for(int x=0;x<=choose;x++){if(operators[x].UserName==""){num++;} | |
} | |
if(operators[num-1].UserName==""){ | |
cout<<"\t\t# 批改失败!该操作员不存在!"<<endl; | |
system("pause"); | |
return; | |
} | |
cout<<"\t\t# 请输出批改操作员账号:"; | |
cin>>UserName_; operators[num-1].UserName=UserName_; | |
cout<<"\t\t# 请输出批改操作员明码:"; | |
cin>>Password_; operators[num-1].Password=Password_; | |
WriteOperatorInformation(operators); | |
} | |
void Administrator::ViewRoomInformation(Room* room) | |
{ | |
cout<<"\t\t 房间号 \t 类型 \t 价格"<<endl; | |
for(int x=0;x<20;x++){if(room[x].RoomNum!=0){cout<<"\t\t"<<room[x].RoomNum<<"\t"<<room[x].RoomType<<"\t"<<room[x].RoomPrice<<endl; | |
} | |
} | |
} | |
void Administrator::ModifyRoomInformation(Room* room) | |
{ | |
int StandardRoomNum, StandardRoomPrice; | |
int DoubleRoomNum, DoubleRoomPrice; | |
int SuiteRoomNum, SuiteRoomPrice; | |
cout<<"\t\t# 因为本酒店客房无限,请确保输出房间总数≤20。"<<endl<<endl; | |
cout<<"\t\t# 请输出标间个数:"; cin>>StandardRoomNum; | |
cout<<"\t\t# 请输出标间价格:"; cin>>StandardRoomPrice; | |
cout<<endl; | |
cout<<"\t\t# 请输出双人间个数:"; cin>>DoubleRoomNum; | |
cout<<"\t\t# 请输出双人间价格:"; cin>>DoubleRoomPrice; | |
cout<<endl; | |
cout<<"\t\t# 请输出套房个数:"; cin>>SuiteRoomNum; | |
cout<<"\t\t# 请输出套房价格:"; cin>>SuiteRoomPrice; | |
cout<<endl; | |
if(StandardRoomNum+DoubleRoomNum+SuiteRoomNum>20){ | |
cout<<"\t\t# 批改失败!您输出的房间个数超出本酒店的房间下限!请保障房间总数≤20!"<<endl; | |
system("pause"); | |
return; | |
} | |
int i[3]={1,0,1},k; | |
for(k=0; k<20; k++) | |
{room[k].RoomNum = 0; | |
room[k].RoomType = "NULL"; | |
room[k].RoomPrice = 0; | |
room[k].IsBooked = false; | |
room[k].IsChecked = false; | |
room[k].GuestName = "NULL"; | |
room[k].GuestID = "NULL"; | |
room[k].GuestTel = "NULL"; | |
room[k].CheckInTime = "NULL"; | |
room[k].BookTime = "NULL"; | |
} | |
for(k=0; k<(StandardRoomNum+DoubleRoomNum+SuiteRoomNum); k++) | |
{room[k].RoomNum=i[0]*100+i[1]*10+i[2]; | |
switch(i[0]) | |
{case 1:{room[k].RoomPrice=StandardRoomPrice; room[k].RoomType="标间";break;} | |
case 2:{room[k].RoomPrice=DoubleRoomPrice; room[k].RoomType="双人间";break;} | |
case 3:{room[k].RoomPrice=SuiteRoomPrice; room[k].RoomType="套房";break;} | |
} | |
if(k==(StandardRoomNum-1) ) | |
i[0]++,i[2]=0; | |
if(k==(DoubleRoomNum+StandardRoomNum-1) ) | |
i[0]++,i[2]=0; | |
i[2]++; | |
} | |
fstream read("酒店房间信息.xls",ios::out); | |
read<<"房间号 \t 类型 \t 价格 \t 是否预订 \t 是否入住 \t 姓名 \t 身份证号 \t 联系方式 \t 预订工夫 \t 入住工夫"<<endl; | |
for(int x=0;x<StandardRoomNum+DoubleRoomNum+SuiteRoomNum;x++) | |
{read<<room[x].RoomNum<<"\t"<<room[x].RoomType<<"\t"<<room[x].RoomPrice<<"\t"<<room[x].IsBooked<<"\t"<<room[x].IsChecked<<"\t"<<room[x].GuestName | |
<<"\t"<<room[x].GuestID<<"\t"<<room[x].GuestTel<<"\t"<<room[x].BookTime<<"\t"<<room[x].CheckInTime<<endl; | |
} | |
read.close(); | |
cout<<"\t\t# 批改胜利!"<<endl; | |
system("pause"); | |
return; | |
} |
main.cpp
#include "Room.h" | |
#include "Administrator.h" | |
#include "Operator.h" | |
#include <iostream> | |
#include <Windows.h> | |
using namespace std; | |
int main() | |
{ | |
int choose=0; | |
int flag; | |
int i;// 操作员的序号 | |
// 房间初始化 | |
Room room[20]; | |
RoomInit(room); | |
// 管理员初始化 | |
Administrator a = Administrator(); | |
// 操作员初始化 | |
Operator operators[20]; | |
OperatorInit(operators); | |
while(true) | |
{ | |
flag = 1; | |
system("cls"); | |
cout<<"\t\t###################################"<<endl; | |
cout<<"\t\t# @曾氏酒店客房管理系统 @ #"<<endl; | |
cout<<"\t\t# #"<<endl; | |
cout<<"\t\t# 1. 管理员登录 #"<<endl; | |
cout<<"\t\t# 2. 操作员登录 #"<<endl; | |
cout<<"\t\t# 3. 查看帮忙 #"<<endl; | |
cout<<"\t\t# 4. 对于本零碎 #"<<endl; | |
cout<<"\t\t# 5. 退出零碎 #"<<endl; | |
cout<<"\t\t# #"<<endl; | |
cout<<"\t\t###################################"<<endl; | |
cout<<"\t\t# 请抉择:"; | |
cin>>choose; | |
system("cls"); | |
switch(choose) | |
{ | |
case 1: | |
if(!AdministratorLogin(a) ){ | |
cout<<"\t\t# 登录失败!若遗记明码可【查看帮忙】!"<<endl;; | |
system("pause"); | |
break; | |
} | |
else{ | |
cout<<"\t\t# 登录胜利!"<<endl; | |
system("pause"); | |
} | |
while(flag) | |
{system("cls"); | |
cout<<"\t\t# 管理员,您好!"<<endl; | |
cout<<"\t\t###################################"<<endl; | |
cout<<"\t\t# @曾氏酒店客房管理系统 @ #"<<endl; | |
cout<<"\t\t# #"<<endl; | |
cout<<"\t\t# 1. 查看操作员信息 #"<<endl; | |
cout<<"\t\t# 2. 减少操作员信息 #"<<endl; | |
cout<<"\t\t# 3. 删除操作员信息 #"<<endl; | |
cout<<"\t\t# 4. 批改操作员信息 #"<<endl; | |
cout<<"\t\t# 5. 查看酒店客房信息 #"<<endl; | |
cout<<"\t\t# 6. 批改酒店客房信息 #"<<endl; | |
cout<<"\t\t# 7. 返回下级目录 #"<<endl; | |
cout<<"\t\t# #"<<endl; | |
cout<<"\t\t###################################"<<endl; | |
cout<<"\t\t# 请抉择:"; | |
cin>>choose; | |
system("cls"); | |
switch(choose) | |
{ | |
case 1: | |
a.ViewOperatorInformation(operators); | |
system("pause"); | |
break; | |
case 2: | |
a.AddOperatorInformation(operators); | |
break; | |
case 3: | |
a.DeleteOperatorInformation(operators); | |
break; | |
case 4: | |
a.ModifyOperatorInformation(operators); | |
break; | |
case 5: | |
a.ViewRoomInformation(room); | |
system("pause"); | |
break; | |
case 6: | |
a.ModifyRoomInformation(room); | |
break; | |
case 7: | |
flag = 0; break; | |
default: break; | |
} | |
} | |
break; | |
case 2: | |
i=OperatorLogin(operators); | |
if(i<0){ | |
cout<<"\t\t# 登录失败!若遗记明码可【查看帮忙】!"<<endl; | |
system("pause"); | |
break; | |
} | |
else{ | |
cout<<"\t\t# 登录胜利!"<<endl; | |
system("pause"); | |
} | |
while(flag) | |
{system("cls"); | |
cout<<"\t\t# 操作员"<<operators[i].getUserName()<<",您好!"<<endl; | |
cout<<"\t\t###################################"<<endl; | |
cout<<"\t\t# @曾氏酒店客房管理系统 @ #"<<endl; | |
cout<<"\t\t# #"<<endl; | |
cout<<"\t\t# 1. 查看客房信息 #"<<endl; | |
cout<<"\t\t# 2. 预 订 房 间 #"<<endl; | |
cout<<"\t\t# 3. 入 住 房 间 #"<<endl; | |
cout<<"\t\t# 4. 住 客 退 房 #"<<endl; | |
cout<<"\t\t# 5. 预 订 查 询 #"<<endl; | |
cout<<"\t\t# 6. 房 间 查 询 #"<<endl; | |
cout<<"\t\t# 7. 住 客 查 询 #"<<endl; | |
cout<<"\t\t# 8. 返回下级目录 #"<<endl; | |
cout<<"\t\t# 9. 退 出 系 统 #"<<endl; | |
cout<<"\t\t# #"<<endl; | |
cout<<"\t\t###################################"<<endl; | |
cout<<"\t\t# 请抉择:"; | |
cin>>choose; | |
system("cls"); | |
switch(choose) | |
{ | |
case 1: | |
operators[i].ViewRoomInformation(room); | |
system("pause"); | |
break; | |
case 2: | |
operators[i].ReserveRoom(room); | |
break; | |
case 3: | |
operators[i].CheckIn(room); | |
break; | |
case 4: | |
operators[i].CheckOut(room); | |
break; | |
case 5: | |
operators[i].BookQuery(room); | |
break; | |
case 6: | |
operators[i].RoomQuery(room); | |
break; | |
case 7: | |
operators[i].GuestQuery(room); | |
break; | |
case 8: | |
operators[i].OperatorQuit(); | |
flag = 0; break; | |
case 9: | |
operators[i].OperatorQuit(); | |
return 0; | |
default: break; | |
} | |
} | |
break; | |
case 3: | |
cout<<"\t\t#####################################################"<<endl; | |
cout<<"\t\t#\t\t@曾氏酒店客房管理系统 @"<<endl; | |
cout<<"\t\t#\t\t @查看帮忙 @"<<endl; | |
cout<<"\t\t#"<<endl; | |
cout<<"\t\t#\t 管理员账号: zsq"<<endl; | |
cout<<"\t\t#\t 管理员明码: 000"<<endl; | |
cout<<"\t\t#"<<endl; | |
cout<<"\t\t#\t 操作员账号: 请登录管理员账号后批改或查问"<<endl; | |
cout<<"\t\t#\t 操作员明码: 请登录管理员账号后批改或查问"<<endl; | |
cout<<"\t\t#"<<endl; | |
cout<<"\t\t#####################################################"<<endl; | |
system("pause"); | |
break; | |
case 4: | |
cout<<"\t################################################################"<<endl; | |
cout<<"\t#\t\t@曾氏酒店客房管理系统 @"<<endl; | |
cout<<"\t#\t\t @对于本零碎 @"<<endl; | |
cout<<"\t#\t"<<endl; | |
cout<<"\t#\t 类:"<<endl; | |
cout<<"\t#\t\tAdministrator - 管理员"<<endl; | |
cout<<"\t#\t\tOperator - 操作员"<<endl; | |
cout<<"\t#\t\tRoom - 客房"<<endl; | |
cout<<"\t#\t"<<endl; | |
cout<<"\t#\t 初始化:"<<endl; | |
cout<<"\t#\t\t 管理员账号密码 - 账号 =zsq,明码 =000"<<endl; | |
cout<<"\t#\t\t 操作员账号密码 - 初始化 10 个,参见 \" 操作员账号信息.txt\""<<endl; | |
cout<<"\t#\t\t 客房数量价格 - 初始化 20 个,参见 \" 酒店房间信息.xlsx\""<<endl; | |
cout<<"\t#\t"<<endl; | |
cout<<"\t#\t 批改信息:"<<endl; | |
cout<<"\t#\t\t 批改管理员信息 - 不可批改,账号 =zsq,明码 =000"<<endl; | |
cout<<"\t#\t\t 批改操作员信息 - 登录管理员账号进行批改"<<endl; | |
cout<<"\t#\t\t 批改客房信息 - 登录管理员账号进行批改"<<endl; | |
cout<<"\t#\t"<<endl; | |
cout<<"\t#\t 管理员操作:"<<endl; | |
cout<<"\t#\t\t1. 查看操作员信息"<<endl; | |
cout<<"\t#\t\t2. 减少操作员信息"<<endl; | |
cout<<"\t#\t\t3. 删除操作员信息"<<endl; | |
cout<<"\t#\t\t4. 批改操作员信息"<<endl; | |
cout<<"\t#\t\t5. 查看酒店客房信息"<<endl; | |
cout<<"\t#\t\t6. 批改酒店客房信息"<<endl; | |
cout<<"\t#\t"<<endl; | |
cout<<"\t#\t 操作员操作:"<<endl; | |
cout<<"\t#\t\t1. 查看客房信息"<<endl; | |
cout<<"\t#\t\t2. 预 订 房 间"<<endl; | |
cout<<"\t#\t\t3. 入 住 房 间"<<endl; | |
cout<<"\t#\t\t4. 住 客 退 房"<<endl; | |
cout<<"\t#\t\t5. 预 订 查 询"<<endl; | |
cout<<"\t#\t\t6. 房 间 查 询"<<endl; | |
cout<<"\t#\t\t7. 住 客 查 询"<<endl; | |
cout<<"\t#\t"<<endl; | |
cout<<"\t#\t 文件信息:"<<endl; | |
cout<<"\t#\t\t 操作员账号信息.txt - 操作员账号和明码"<<endl; | |
cout<<"\t#\t\t 酒店房间信息.xlsx - 酒店房间的各种信息"<<endl; | |
cout<<"\t#\t\t 操作员工作日志.xlsx - 操作员所有操作"<<endl; | |
cout<<"\t#\t"<<endl; | |
cout<<"\t################################################################"<<endl; | |
system("pause"); | |
break; | |
case 5: | |
cout<<"\t\t###################################"<<endl; | |
cout<<"\t\t# @曾氏酒店客房管理系统 @ #"<<endl; | |
cout<<"\t\t# #"<<endl; | |
cout<<"\t\t# 再见!#"<<endl; | |
cout<<"\t\t# designed by 曾诗琦 #"<<endl; | |
cout<<"\t\t# LZU 320180943570 #"<<endl; | |
cout<<"\t\t# #"<<endl; | |
cout<<"\t\t###################################"<<endl; | |
return 0; | |
default : break; | |
} | |
} | |
return 0; | |
} |