您好,登录后才能下订单哦!
本文小编为大家详细介绍“C++如何实现旅馆住宿管理系统”,内容详细,步骤清晰,细节处理妥当,希望这篇“C++如何实现旅馆住宿管理系统”文章能帮助大家解决疑惑,下面跟着小编的思路慢慢深入,一起来学习新知识吧。
一:课程设计要实现的目的
1.预定房间:输入顾客的姓名和身份证号码,然后有单人间/天/100元、双人间/天/200元、标准间/天/300元 三种房间类型可以选择。最后=输入预定天数,从而系统计算出房费与预定的房间号。
2.入住功能:分该顾客已订和未订房间的两种情况。对于已经预定的顾客,通过输入姓名与身份证号码从而入住预定的房间;对于没有预定的顾客,执行入住功能,过程与预定房间类似。
3.退房功能:输入要退房的顾客姓名与身份证号码来查找该顾客,然后输入该顾客实际所住的天数,计算出实际应付的房费与多支付或少支付的费用。
4.查询功能:分为房间信息查询与顾客了信息查询两种查询方式。
房间信息查询可以显示出空房间、已预定房间和已入住房间的房间号和房间数量。
顾客信息查询分为按姓名或按身份证号查找。两种方式都是查询出该顾客的预付费用和房间信息。
5.退出功能:退出系统。
二:总体设计
一个旅馆管理系统,必然涉及到房间对象,顾客对象等实体。这个系统初始化了60个房间,其中房间分三个等级,每个等级的价格不一样,可以通过房间编号得到房间的等级。然后就是房间的分配问题,当有顾客要求预定或入住时,系统能够根据用户要求入住的等级到相应等级的房间中去查找一个还没有预定的房间和一个没有入住的空闲房间。
当启动程序后,从Main函数开始运行,程序首先调用initial_room函数初始化60个房间的信息,包括房间编号,房间等级,房间价格,房间状态。其中房间编号和房间等级有直接联系,只要知道了房间编号就可以通过计算得到该房间的等级,房间状态初始化时都等于0,表示该房间既没有被预定,也没有被入住,为空房间。然后调用welcome函数,考虑到作为一个宾馆管理系统的安全性,在本函数中要求只有通过输入了正确的用户名和密码才能操作系统。此处账号密码都是123。当通过登陆认证后,就进入宾馆管理系统了,在这里,系统给操作者显示一个操作菜单:1.预定 2.入住 3.退房 4.查询 5.退出,选择不同的数字时就实现不同的功能。
三:详细设计过程
1. 预定:作为一个旅馆管理系统,顾客可以提前进行房间的预定,操作者能根据用户的需求查询到适合顾客的房间。在这个系统中,这个功能是在Book_Room函数中实现的。首先,构造一个顾客对象,输入顾客的信息,然后设置该顾客预定客房的天数,设置顾客预定客房类型,根据用户需要的客放标准到相应的类型客房去查找一个一个既没有被预定也没有入住的房间,然后把该房间对象结构体的状态修改为已预定状态,同时将顾客对象的预定房间号属性和住房费用计算出来并显示到界面上,最后将住房顾客数加1。
2. 入住:这个功能是在go_in函数中实现的,程序首先判断顾客是否订房了,如果预定了房间,则要求输入顾客姓名和身份证号码,然后在所有的顾客中去查找此姓名和身份证号码的顾客,如果匹配了就取得其房间号,然后根据房间号计算出该房间的类型,再根据该顾客要求预定住房的天数和该房间类型的价格计算出该顾客要缴纳的费用,同时显示到界面上,这时操作者对顾客进行收费,同时将该住房的状态修改为已入住状态(State=2);如果顾客没有先预定房间,在这里可以实现先查找空房再入住的功能,同预定房间功能一样,先建立一个顾客对象,然后设置入住天数,选择住房类型,根据房间类型查询到一个空房,同时修改该房间的状态为已入住状态,计算房费直接执行收费,同时将顾客数加1。
3. 退房:此函数是再go_out函数中实现的。首先,输入要退房的顾客的姓名和身份证号码,再输入该顾客的实际住的天数,系统计算出顾客的费用。用switch函数根据房间等级和所住天数来判断是要给顾客退费用还是顾客需要补交费用。
4. 查询:此功能在inquire函数中实现。信息查询分为房间信息查询和顾客信息查询。对顾客信息查询,有两种方式:按姓名查询;按身份证号查询。通过查询可以得知每个房间的信息和每个顾客的房间信息与预付费用。
四:课设实现
1.登陆
//登陆
void function::welcome() {
system("color 3E");
char name[4],pass[7];
cout<<"请输入用户名和密码:"<<endl;
cin>>name;
cin>>pass;
while((strcmp(name,"123")!=0)||(strcmp(pass,"123")!=0)) {
cout<<"用户名或密码输入有误,请重新输入!"<<endl;
cin>>name;
cin>>pass;
}
cout<<endl;
cout<<endl;
cout<<" ---------------------------"<<endl;
cout<<" 欢迎使用旅馆住宿管理系统!"<<endl;
cout<<" ---------------------------"<<endl;
cout<<endl;
system("pause");
system("cls");
}
2.初始化房间
//初始化
void function::initial_room() {
int j;
int k=101;
for(j=0; j<20; j++) {
room[j].number=k++;
room[j].rad=1;
room[j].price=100;
room[j].state=0;
}
k=201;
for(j=20; j<40; j++) {
room[j].number=k++;
room[j].rad=2;
room[j].price=200;
room[j].state=0;
}
k=301;
for(j=40; j<60; j++) {
room[j].number=k++;
room[j].rad=3;
room[j].price=300;
room[j].state=0;
}
}
int main() {
char choice='1';
function m;
m.initial_room(); //初始化60个房间
m.welcome();
//验证
while(choice=='1') {
m.menu();//功能
cout<<endl;
cout<<"1. 继续使用 2. 退出 "<<endl;
cin>>choice;
cout<<endl;
}
}
3.订房
//订房
void function::book_room() {
customer[i]=new Customer;
int room_kind,day;
cout<<"请您选择预定房间类型:\n";
cout<<"1.单人间/天/100元\n2.双人间/天/200元\n3.标准间/天/300元"<<endl;
cin>>room_kind;
cout<<"请输入预定天数"<<endl;
cin>>day;
customer[i]->set_day(day);
switch(room_kind) {
int n;
case 1:
cout<<"住房费用总共为: "<<day*100<<"元"<<endl;
for(n=0; n<20; n++) { //从第一个级别的房间中查找一个空闲的房间
if(room[n].state==0) { //state=0表示该住房没有被预定的
cout<<"预定成功 房间号码为: "<<room[n].number<<endl;
room[n].state=1;
customer[i]->set_room_number(room[n].number);
break;
}
}
break;
case 2:
cout<<"住房费用总共为: "<<day*200<<" 元"<<endl;
for(n=20; n<40; n++) {
if(room[n].state==0) {
cout<<"预定成功 房间号码为: "<<room[n].number<<endl;
room[n].state=1;
customer[i]->set_room_number(room[n].number);
break;
}
}
break;
case 3: {
cout<<"住房费用总共为: "<<day*300<<" 元"<<endl;
for(n=40; n<60; n++) {
if(room[n].state==0) {
cout<<"预订成功 房间号码为: "<<room[n].number<<endl;
room[n].state=1;
customer[i]->set_room_number(room[n].number);
break;
}
}
break;
}
default:
cout<<"选择有误"<<endl;
break;
}
i++; //住房的顾客数加1
}
4.入住
//入住
void function::go_in() {
char name1[10],id1[19];
int q,prepaid;
cout<<"该顾客是否已订房 (1. 已订 2. 没订) "<<endl;
cin>>q;
if(q==1) {
cout<<"请输入顾客的姓名:"<<endl;
cin>>name1;
cout<<"请输入顾客的身份证号码:"<<endl;
cin>>id1;
//i:顾客人数
for(int j=0; j<=i; j++) {
if((strcmp(customer[j]->get_name(),name1)==0)&&(strcmp(customer[j]->get_ID(),id1)==0)) {
int num=customer[j]->get_room_number();
cout<<"顾客"<<name1<<"入住 房间号码为: "<<num<<endl;
switch(num/100) {
case 6:
prepaid=customer[j]->get_day()*100;
customer[j]->set_prepaid(prepaid);
cout<<"请收费用 "<<prepaid<<"元"<<endl;
room[num%100-1].state=2; //修改房间状态为入住状态
break;
case 7:
prepaid=customer[j]->get_day()*200;
customer[j]->set_prepaid(prepaid);
cout<<"请收费用 "<<prepaid<<"元"<<endl;
room[19+num%100].state=2;
break;
case 8:
prepaid=customer[j]->get_day()*300;
customer[j]->set_prepaid(prepaid);
cout<<"请收费用 "<<prepaid<<"元"<<endl;
room[39+num%100].state=2;
break;
}
break;
}
}
} else {
customer[i]=new Customer;
int roomkind;
int day;
cout<<"请输入要预定的天数:"<<endl;
cout<<"1.单人间/天/100元\n2.双人间/天/200元\n3.标准间/天/300元"<<endl;
cin>>roomkind;
cout<<"请输入住宿天数:"<<endl;
cin>>day;
customer[i]->set_day(day);
switch(roomkind) {
int n;
case 1:
prepaid=day*100;
customer[i]->set_prepaid(prepaid);
cout<<"请收费用 "<<prepaid<<"元"<<endl;
for(n=0; n<20; n++) {
if(room[n].state==0) {
cout<<"入住房间号码为: "<<room[n].number<<endl;
room[n].state=2;
customer[i]->set_room_number(room[n].number);
break;
}
}
break;
case 2:
prepaid=day*200;
customer[i]->set_prepaid(prepaid);
cout<<"请收费用 "<<prepaid<<"元"<<endl;
for(n=20; n<40; n++) {
if(room[n].state==0) {
cout<<"入住房间号为: "<<room[n].number<<endl;
room[n].state=2;
customer[i]->set_room_number(room[n].number);
break;
}
}
break;
case 3:
prepaid=day*300;
customer[i]->set_prepaid(prepaid);
cout<<"请收费用 "<<prepaid<<"元"<<endl;
for(n=40; n<60; n++) {
if(room[n].state==0) {
cout<<"入住房间号为: "<<room[n].number<<endl;
room[n].state=2;
customer[i]->set_room_number(room[n].number);
break;
}
}
break;
}
i++;
}
}
5.退房
//退房
void function::go_out() {
char name2[10],id2[19];
int room_number;
int day;//多或少天数
cout<<"请输入要退房的顾客姓名和身份证号码:"<<endl;
cin>>name2;
cin>>id2;
cout<<"请输入该顾客实际所住天数:"<<endl;
int day2;
cin>>day2;
int j;
for(j=0; j<i; j++) {
if((strcmp(customer[j]->get_name(),name2)==0)&&(strcmp(customer[j]->get_ID(),id2)==0)) {
room_number=customer[j]->get_room_number();
int w;
w=room_number/100;
int day1;
day1=customer[j]->get_day();
day=day1-day2;
switch(w) {
case 1:
cout<<"顾客的房间号是"<<room_number<<" :为单人间,每天100元"<<endl;
cout<<"该顾客预付了房费 "<<customer[j]->get_prepaid()<<"元, 实际消费 "<<day2*100<<"元"<<endl;
cout<<endl;
if(day>0)
cout<<"请退给该顾客 "<<day*100<<" 元"<<endl;
if(day<0)
cout<<"请补收该顾客住房费 "<<-day*100<<" 元"<<endl;
break;
case 2:
cout<<"顾客的房间号是"<<room_number<<" :为双人间,每天200元"<<endl;
cout<<"该顾客预付了房费 "<<customer[j]->get_prepaid()<<"元, 实际消费 "<<day2*200<<"元"<<endl;
cout<<endl;
if(day>0)
cout<<"请退给该顾客 "<<day*200<<" 元"<<endl;
if(day<0)
cout<<"请补收该顾客住房费 "<<-day*200<<" 元"<<endl;
break;
case 3:
cout<<"顾客的房间号是"<<room_number<<" :为标准间,每天300元"<<endl;
cout<<"该顾客预付了房费 "<<customer[j]->get_prepaid()<<"元, 实际消费 "<<day2*300<<"元"<<endl;
cout<<endl;
if(day>0)
cout<<"请退给该顾客 "<<day*300<<" 元"<<endl;
if(day<0)
cout<<"请补收该顾客住房费 "<<-day*300<<" 元"<<endl;
break;
}
cout<<endl;
cout<<"确认退房,请按1: "<<endl;
char v;
cin>>v;
if(v=='1') {
for(int k=0; k<60; k++) {
if(room[k].number==customer[j]->get_room_number())
room[k].state=0;
}
i--;
for(; j<i; j++) {
customer[j]=customer[j+1];
}
delete customer[i];
}
}
else
{
cout<<"无此顾客信息"<<endl;
break;
}
}
}
6.查询
//查询
void function::inquire() {
char option;
cout<<"1.房间信息查询, 2.顾客信息查询: "<<endl;
cin>>option;
if(option=='1') {
int j;
int k=0;
cout<<endl;
cout<<"空房间:"<<endl;
for(j=0; j<60; j++) {
if(room[j].state==0) {
if(k%10==0) cout<<endl;//一行十个
cout<<room[j].number<<'\t';
k++;
}
}
cout<<endl;
cout<<endl;
k=0;
cout<<"已预订房间:"<<endl;
for(j=0; j<60; j++) {
if(room[j].state==1) {
if(k%10==0) cout<<endl;
cout<<room[j].number<<'\t';
k++;
}
}
k=0;
cout<<endl;
cout<<endl;
cout<<"已入住房间:"<<endl;
for(j=0; j<60; j++) {
if(room[j].state==2) {
if(k%10==0) cout<<endl;
cout<<room[j].number<<'\t';
k++;
}
}
cout<<endl;
cout<<endl;
} else if(option=='2') {
cout<<"1.按姓名查询, 2.按身份证查询: "<<endl;
char option;
cin>>option;
if(option=='1') {
char name3[10];
cout<<"请输入顾客的姓名: ";
cin>>name3;
for(int j=0; j<=i; j++) {
if(strcmp(customer[j]->get_name(),name3)==0) {
cout<<name3<<"的信息如下:"<<endl;
cout<<"\t"<<"房间号: "<<customer[j]->get_room_number()<<endl;
cout<<"\t"<<"预付费用: "<<customer[j]->get_prepaid()<<endl;
break;
}
else
{
cout<<"无此顾客信息"<<endl;
break;
}
}
}
if(option=='2') {
char id3[10];
cout<<"请输入顾客的身份证号码: "<<endl;
cin>>id3;
for(int j=0; j<=i; j++) {
if(strcmp(customer[j]->get_ID(),id3)==0) {
cout<<customer[j]->get_name()<<"的房间信息:"<<endl;
cout<<"\t"<<"房间号: "<<customer[j]->get_room_number()<<endl;
cout<<"\t"<<"预付房费: "<<customer[j]->get_prepaid()<<endl;
break;
}
else
{
cout<<"无此顾客信息"<<endl;
break;
}
}
}
}
}
(1)房间信息查询
(2)顾客信息查询
完整的放这喽
//账号为123
//密码为123
#include<iostream>
#include<cstdlib>
#include<cstring>
using namespace std;
int i=0;
struct Room {
int number;
int rad;
int price;
int state;
};
class Customer {
public:
Customer();
void set_name(char *n) {
strcpy(name,n);
}
void set_ID(char *p) {
strcpy(ID,p);
}
void set_room_number(int n) {
room_number=n;
}
void set_day(int d) {
day=d;
}
void set_prepaid(int p) {
prepaid=p;
}
char *get_name() {
return name;
}
char *get_ID() {
return ID;
}
int get_room_number() {
return room_number;
}
int get_day() {
return day;
}
int get_prepaid() {
return prepaid;
}
virtual ~Customer();
private:
char name[10],ID[19];
int room_number;
int prepaid;
int change;
int day;
};
Customer::Customer() {//构造函数
cout<<"请您输入顾客的姓名"<<endl;
cin>>name;
cout<<"请您输入顾客的身份证号码"<<endl;
cin>>ID;
prepaid=day=0;
}
Customer::~Customer() {//析构函数
cout<<"该顾客退房成功!"<<endl;
}
Room room[60];
Customer *customer[60];
class function
{
public:
void initial_room();
void welcome();
void menu();
void book_room();
void go_in();
void go_out();
void inquire();
void out();
};
int main() {
char choice='1';
function m;
m.initial_room(); //初始化60个房间
m.welcome();
//验证
while(choice=='1') {
m.menu();//功能
cout<<endl;
cout<<"1. 继续使用 2. 退出 "<<endl;
cin>>choice;
cout<<endl;
}
}
//登陆
void function::welcome() {
system("color 3E");
char name[4],pass[7];
cout<<"请输入用户名和密码:"<<endl;
cin>>name;
cin>>pass;
while((strcmp(name,"123")!=0)||(strcmp(pass,"123")!=0)) {
cout<<"用户名或密码输入有误,请重新输入!"<<endl;
cin>>name;
cin>>pass;
}
cout<<endl;
cout<<endl;
cout<<" ---------------------------"<<endl;
cout<<" 欢迎使用旅馆住宿管理系统!"<<endl;
cout<<" ---------------------------"<<endl;
cout<<endl;
system("pause");
system("cls");
}
void function::menu() {
function n;
char x;
cout<<"\t\t请选择功能: "<<endl;
cout<<" \t 1.预定 \t2.入住 "<<endl;
cout<<" \t 3.退房 \t4.查询"<<endl;
cout<<" \t 5.退出 \t"<<endl;
cin>>x;
switch(x) {
case '1':
n.book_room();
system("pause");
system("cls");
break;
case '2':
n.go_in();
system("pause");
system("cls");
break;
case '3':
n.go_out();
system("pause");
system("cls");
break;
case '4':
n.inquire();
system("pause");
system("cls");
break;
case '5':
n.out();
break;
default:
cout<<"输入有误,请重新输入"<<endl;
cin>>x;
}
}
//订房
void function::book_room() {
customer[i]=new Customer;
int room_kind,day;
cout<<"请您选择预定房间类型:\n";
cout<<"1.单人间/天/100元\n2.双人间/天/200元\n3.标准间/天/300元"<<endl;
cin>>room_kind;
cout<<"请输入预定天数"<<endl;
cin>>day;
customer[i]->set_day(day);
switch(room_kind) {
int n;
case 1:
cout<<"住房费用总共为: "<<day*100<<"元"<<endl;
for(n=0; n<20; n++) { //从第一个级别的房间中查找一个空闲的房间
if(room[n].state==0) { //state=0表示该住房没有被预定的
cout<<"预定成功 房间号码为: "<<room[n].number<<endl;
room[n].state=1;
customer[i]->set_room_number(room[n].number);
break;
}
}
break;
case 2:
cout<<"住房费用总共为: "<<day*200<<" 元"<<endl;
for(n=20; n<40; n++) {
if(room[n].state==0) {
cout<<"预定成功 房间号码为: "<<room[n].number<<endl;
room[n].state=1;
customer[i]->set_room_number(room[n].number);
break;
}
}
break;
case 3: {
cout<<"住房费用总共为: "<<day*300<<" 元"<<endl;
for(n=40; n<60; n++) {
if(room[n].state==0) {
cout<<"预订成功 房间号码为: "<<room[n].number<<endl;
room[n].state=1;
customer[i]->set_room_number(room[n].number);
break;
}
}
break;
}
default:
cout<<"选择有误"<<endl;
break;
}
i++; //住房的顾客数加1
}
//入住
void function::go_in() {
char name1[10],id1[19];
int q,prepaid;
cout<<"该顾客是否已订房 (1. 已订 2. 没订) "<<endl;
cin>>q;
if(q==1) {
cout<<"请输入顾客的姓名:"<<endl;
cin>>name1;
cout<<"请输入顾客的身份证号码:"<<endl;
cin>>id1;
//i:顾客人数
for(int j=0; j<=i; j++) {
if((strcmp(customer[j]->get_name(),name1)==0)&&(strcmp(customer[j]->get_ID(),id1)==0)) {
int num=customer[j]->get_room_number();
cout<<"顾客"<<name1<<"入住 房间号码为: "<<num<<endl;
switch(num/100) {
case 6:
prepaid=customer[j]->get_day()*100;
customer[j]->set_prepaid(prepaid);
cout<<"请收费用 "<<prepaid<<"元"<<endl;
room[num%100-1].state=2; //修改房间状态为入住状态
break;
case 7:
prepaid=customer[j]->get_day()*200;
customer[j]->set_prepaid(prepaid);
cout<<"请收费用 "<<prepaid<<"元"<<endl;
room[19+num%100].state=2;
break;
case 8:
prepaid=customer[j]->get_day()*300;
customer[j]->set_prepaid(prepaid);
cout<<"请收费用 "<<prepaid<<"元"<<endl;
room[39+num%100].state=2;
break;
}
break;
}
}
} else {
customer[i]=new Customer;
int roomkind;
int day;
cout<<"请输入要预定的天数:"<<endl;
cout<<"1.单人间/天/100元\n2.双人间/天/200元\n3.标准间/天/300元"<<endl;
cin>>roomkind;
cout<<"请输入住宿天数:"<<endl;
cin>>day;
customer[i]->set_day(day);
switch(roomkind) {
int n;
case 1:
prepaid=day*100;
customer[i]->set_prepaid(prepaid);
cout<<"请收费用 "<<prepaid<<"元"<<endl;
for(n=0; n<20; n++) {
if(room[n].state==0) {
cout<<"入住房间号码为: "<<room[n].number<<endl;
room[n].state=2;
customer[i]->set_room_number(room[n].number);
break;
}
}
break;
case 2:
prepaid=day*200;
customer[i]->set_prepaid(prepaid);
cout<<"请收费用 "<<prepaid<<"元"<<endl;
for(n=20; n<40; n++) {
if(room[n].state==0) {
cout<<"入住房间号为: "<<room[n].number<<endl;
room[n].state=2;
customer[i]->set_room_number(room[n].number);
break;
}
}
break;
case 3:
prepaid=day*300;
customer[i]->set_prepaid(prepaid);
cout<<"请收费用 "<<prepaid<<"元"<<endl;
for(n=40; n<60; n++) {
if(room[n].state==0) {
cout<<"入住房间号为: "<<room[n].number<<endl;
room[n].state=2;
customer[i]->set_room_number(room[n].number);
break;
}
}
break;
}
i++;
}
}
//退房
void function::go_out() {
char name2[10],id2[19];
int room_number;
int day;//多或少天数
cout<<"请输入要退房的顾客姓名和身份证号码:"<<endl;
cin>>name2;
cin>>id2;
cout<<"请输入该顾客实际所住天数:"<<endl;
int day2;
cin>>day2;
int j;
for(j=0; j<i; j++) {
if((strcmp(customer[j]->get_name(),name2)==0)&&(strcmp(customer[j]->get_ID(),id2)==0)) {
room_number=customer[j]->get_room_number();
int w;
w=room_number/100;
int day1;
day1=customer[j]->get_day();
day=day1-day2;
switch(w) {
case 1:
cout<<"顾客的房间号是"<<room_number<<" :为单人间,每天100元"<<endl;
cout<<"该顾客预付了房费 "<<customer[j]->get_prepaid()<<"元, 实际消费 "<<day2*100<<"元"<<endl;
cout<<endl;
if(day>0)
cout<<"请退给该顾客 "<<day*100<<" 元"<<endl;
if(day<0)
cout<<"请补收该顾客住房费 "<<-day*100<<" 元"<<endl;
break;
case 2:
cout<<"顾客的房间号是"<<room_number<<" :为双人间,每天200元"<<endl;
cout<<"该顾客预付了房费 "<<customer[j]->get_prepaid()<<"元, 实际消费 "<<day2*200<<"元"<<endl;
cout<<endl;
if(day>0)
cout<<"请退给该顾客 "<<day*200<<" 元"<<endl;
if(day<0)
cout<<"请补收该顾客住房费 "<<-day*200<<" 元"<<endl;
break;
case 3:
cout<<"顾客的房间号是"<<room_number<<" :为标准间,每天300元"<<endl;
cout<<"该顾客预付了房费 "<<customer[j]->get_prepaid()<<"元, 实际消费 "<<day2*300<<"元"<<endl;
cout<<endl;
if(day>0)
cout<<"请退给该顾客 "<<day*300<<" 元"<<endl;
if(day<0)
cout<<"请补收该顾客住房费 "<<-day*300<<" 元"<<endl;
break;
}
cout<<endl;
cout<<"确认退房,请按1: "<<endl;
char v;
cin>>v;
if(v=='1') {
for(int k=0; k<60; k++) {
if(room[k].number==customer[j]->get_room_number())
room[k].state=0;
}
i--;
for(; j<i; j++) {
customer[j]=customer[j+1];
}
delete customer[i];
}
}
else
{
cout<<"无此顾客信息"<<endl;
break;
}
}
}
//查询
void function::inquire() {
char option;
cout<<"1.房间信息查询, 2.顾客信息查询: "<<endl;
cin>>option;
if(option=='1') {
int j;
int k=0;
cout<<endl;
cout<<"空房间:"<<endl;
for(j=0; j<60; j++) {
if(room[j].state==0) {
if(k%10==0) cout<<endl;//一行十个
cout<<room[j].number<<'\t';
k++;
}
}
cout<<endl;
cout<<endl;
k=0;
cout<<"已预订房间:"<<endl;
for(j=0; j<60; j++) {
if(room[j].state==1) {
if(k%10==0) cout<<endl;
cout<<room[j].number<<'\t';
k++;
}
}
k=0;
cout<<endl;
cout<<endl;
cout<<"已入住房间:"<<endl;
for(j=0; j<60; j++) {
if(room[j].state==2) {
if(k%10==0) cout<<endl;
cout<<room[j].number<<'\t';
k++;
}
}
cout<<endl;
cout<<endl;
} else if(option=='2') {
cout<<"1.按姓名查询, 2.按身份证查询: "<<endl;
char option;
cin>>option;
if(option=='1') {
char name3[10];
cout<<"请输入顾客的姓名: ";
cin>>name3;
for(int j=0; j<=i; j++) {
if(strcmp(customer[j]->get_name(),name3)==0) {
cout<<name3<<"的信息如下:"<<endl;
cout<<"\t"<<"房间号: "<<customer[j]->get_room_number()<<endl;
cout<<"\t"<<"预付费用: "<<customer[j]->get_prepaid()<<endl;
break;
}
else
{
cout<<"无此顾客信息"<<endl;
break;
}
}
}
if(option=='2') {
char id3[10];
cout<<"请输入顾客的身份证号码: "<<endl;
cin>>id3;
for(int j=0; j<=i; j++) {
if(strcmp(customer[j]->get_ID(),id3)==0) {
cout<<customer[j]->get_name()<<"的房间信息:"<<endl;
cout<<"\t"<<"房间号: "<<customer[j]->get_room_number()<<endl;
cout<<"\t"<<"预付房费: "<<customer[j]->get_prepaid()<<endl;
break;
}
else
{
cout<<"无此顾客信息"<<endl;
break;
}
}
}
}
}
//初始化
void function::initial_room() {
int j;
int k=101;
for(j=0; j<20; j++) {
room[j].number=k++;
room[j].rad=1;
room[j].price=100;
room[j].state=0;
}
k=201;
for(j=20; j<40; j++) {
room[j].number=k++;
room[j].rad=2;
room[j].price=200;
room[j].state=0;
}
k=301;
for(j=40; j<60; j++) {
room[j].number=k++;
room[j].rad=3;
room[j].price=300;
room[j].state=0;
}
}
void function::out()
{
return;
}
读到这里,这篇“C++如何实现旅馆住宿管理系统”文章已经介绍完毕,想要掌握这篇文章的知识点还需要大家自己动手实践使用过才能领会,如果想了解更多相关内容的文章,欢迎关注亿速云行业资讯频道。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。