C专业课程设计·大酒店标准管理系统_第1页
C专业课程设计·大酒店标准管理系统_第2页
C专业课程设计·大酒店标准管理系统_第3页
C专业课程设计·大酒店标准管理系统_第4页
C专业课程设计·大酒店标准管理系统_第5页
已阅读5页,还剩35页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1.课题介绍………032.设计方案………043.具体设计及截屏图……………054.关键代码分析…………………105.测试……………156.课题总结和体会………………177.参考文件………188.源代码…………191.课题介绍客房管理系统是依据某酒店对客房管理实际情况进行编写,关键目标是为了方便酒店对客房实际情况进行集中查询和管理工作,以提升整个酒店工作。经过电脑及生活中调查研究,依据客人经济水平和生活理念,客房类型已趋向于多样化,有标准房,单人房,VIP间,甚至总统套房。而初步设定经过客房编号、类型、价格来定位一个客房管理系统。客房是一个对外服务内容,为了客人住宿要求,所以系统需要实现客房信息录入、修改和删除功效。客人对剩下客房需要进行选择,系统必需实现对应查询、排序和输出功效,使客人择优而居。此次课程设计需要实现是——客房管理系统链表实现。关键实现功效包含:客房信息录入、修改、删除、剩下客房信息查询、排序、输出。客房信息可写入文件,也可从文件中读取。客房信息包含数据有客房编号、客房类型、定房日期、客房内容(设施)、定房使用期等。2.设计方案根据需求分析所得,客房信息系统有以下多个功效模块:1.添加录入信息模块;编写指针摸板,定义临时客房间数,包含其各项类组员,编号,类型,定房日期,价格,客房内容,入住天数。3.修改客房信息模块;读取保留客房信息数据,依据客房编号查找所需修改客房信息,然后依据具体所需,修改组员参数,并保留。4.删除客房信息模块;从保留中文件中读取信息,删除需要删除信息,完善现在客房运作。5.查询剩下客房函数;分按编号、类型、价格查询,这么能够更含有些人性化来选择所剩下客房,从而进行日常安排。6.排序剩下客房模块;依据具体所需排序,能够是编号、价格或类型,本系统中依据是客房入住天数来排序。7.输出剩下客房函数;输出依据系统所需排序后客房信息,本系统中是依据了客人入住使用期即天数来立即了解空出房间。由上述需求分析可得,系统功效模块图图1所表示。录入客房信息录入客房信息客房信息管理系统查询剩下客房信息排序剩下客房信息输出剩下客房信息保留客房信息修改客房信息删除客房信息退出系统图12.具体设计及截屏图1、类设计依据上述需求分析,有客房类和链表类。(1)客房类系统研究客房cGuestroom类中组员:ID[SIZE]是客房编号,Type[SIZE]是客房类型,Book[SIZE]是定房日期,Price[SIZE]是每间客房价格,StayTime[SIZE]是定房使用期,Function[SIZE]是客房关键内容(如浴室、卫生间、网线等设施),标志flag和结构函数cGuestroom()。客房类UML图如(图2)所表示:classcGuestroomclasscGuestroom+ID[BUFSIZE]:char//客房编号+Type[BUFSIZE]:char//客房类型+Book[BUFSIZE]:char//定房日期+Function[BUFSIZE]:char//客房内容+StayTime:int//定房使用期+flay:bool//标志+cGuestroom()//结构函数初始化 图2 (2)链表类在tList类中,有组员:结构函数tList(),创建链表Create(),判定链表是否为空函数Empty()const,从尾部插入一个元素函数Insert(constTe),返回第i个节点函数GetcNode(inti),在链表中查询某个值函数boolFind(constTe),析构函数~tList(),头节点head。链表类UML图如(图3)所表示:tListList+tList();+Create():void+Empty()const:bool+Insert(conste:T):void+*GetcNode(i:int):cNode<T>+Find(conste:T):bool+~tList();+*head:cNode<T> 图32.界面设计:(1)主界面设计主界面中显示客房管理系统全部信息,客房信息录入,客房信息保留,客房信息修改,客房信息删除,剩下客房查询,剩下客房排序,剩下客房输出,客房信息管理系统图4所表示。图4主界面(2)分界面:客房信息录入设计提醒输入客房编号,客房类型,客人定房日期,客房价格,客房中关键内容,客房定房使用期。客房信息录入图5所表示。图5录入客房信息分界面(3)分界面:客房信息保留设计针对第一步客房信息输入及以后信息修改、删除做一个文件保留。客房信息保留图6所表示。图6保留客房信息分界面(4)分界面:客房信息修改设计提醒依据编号进行客房信息修改,输入要修改内容,如不修改项目就远洋输出。客房信息修改界面图7所表示。图7修改客房信息分界面(5)分界面:客房信息删除设计提醒进入删除截面,依据客房编号查找所需删除客房信息。客房信息删除界面图8所表示。图8删除客房信息分界面(6)分界面:剩下客房信息查询设计在保留完所修改或删除客房信息,查询剩下客房信息,按提醒进入剩下客房查询界面,有按编号、类型、价格查询,依据拥护自主选择。查询剩下客房信息界面图9所表示。图9查询客房信息分界面(7)剩下客房信息排序设计按提醒进行剩下客房排序,本系统中是以客人入住天数排序,显示器幕图10所表示。(8)分界面:剩下客房信息输出设计在排序完后剩下客房中,输出全部客房信息,以检验客房经营情况。剩下客房信息输出界面图10所表示。图10输出剩下客房信息4.关键代码分析(1)系统登录在主函数中,输出客房信息系统各功效提醒。选择需要实施功效序号,由switch判定和选择所需要实施功效。选择1:实施客房信息录入;选择2:实施保留客房信息;选择3:实施教工基础信息保留;选择4:实施教工基础信息删除;选择5:实施教工工资按从高到低排序;选择6:实施教工基础信息修改;选择7:实施教工基础信息查询;选择8:退出;主函数:intmain(){tList<cGuestroom>tListMedic;tListMedic.Create();//创建链表ReadData(&tListMedic); while(1) {cout<<"\n\n客房管理系统\n\n";cout<<"----------------------------------\n\n"; cout<<"1.客房信息录入\n\n"; cout<<"2:客房信息保留\n\n"; cout<<" 3.客房信息修改\n\n"; cout<<"4.客房信息删除\n\n"; cout<<" 5.剩下客房信息查询\n\n";cout<<"6.剩下客房信息排序\n\n"; cout<<" 7.剩下客房信息输出\n\n"; cout<<"8.退出系统\n\n"; cout<<"请选择:"; intchoose=0; cin>>choose; switch(choose)//用户选择 {case1:AddtheGuestroom(&tListMedic);break;//输入客房信息 case2:SaveData(&tListMedic);break;//客房信息信息保留 case3:ModifytheGuestroom(&tListMedic);break;//修改客房信息case4:DeletetheGuestroom(&tListMedic);break;//删除客房信息case5:FindtheremainGuestroom(&tListMedic);break;//查询剩下客房信息 case6:RanktheremainGuestroom(&tListMedic);break;//排序剩下客房信息 case7:OutputtheremainGuestroom(&tListMedic);break;//输出剩下客房信息 case8:exit(0);//退出 default:break;} return0;}}在读取数据库中,能够从以有文件中读取数据到程序中,避免了程序反复输入数据,有利于后面信息修改、删除等功效。读取数据库:voidReadData(tList<cGuestroom>*tListMedic)//读取数据库{ charbuf[BUFSIZE]; ifstreamifile("Guestroom.txt",ios_base::in); //创建一个输出文件流对象 if(!ifile) { cerr<<"读取时打开文件犯错!"<<endl; } cGuestroomGuestroom; while(ifile.getline(buf,BUFSIZE))//遍历文本,读取数据 { ifile.getline(buf,BUFSIZE); strcpy(Guestroom.ID,buf);//读取客房编号 memset(buf,0,BUFSIZE); ifile.getline(buf,BUFSIZE);//读取客房类型 strcpy(Guestroom.Type,buf); memset(buf,0,BUFSIZE); ifile.getline(buf,BUFSIZE);//读取提前定房日期 strcpy(Guestroom.Book,buf); memset(buf,0,BUFSIZE); ifile.getline(buf,BUFSIZE);//读取价格 strcpy(Guestroom.Price,buf); memset(buf,0,BUFSIZE); ifile.getline(buf,BUFSIZE);//读取客房关键内容 strcpy(Guestroom.Function,buf); memset(buf,0,BUFSIZE); ifile.getline(buf,BUFSIZE);//读取入住使用期 Guestroom.StayTime=atoi(buf); memset(buf,0,BUFSIZE); Guestroom.flag=true; tListMedic->Insert(Guestroom); } cout<<"读取数据成功!\n\n"; ifile.close();//关闭文件 return;}(2)信息添加客房信息录入,创建cGuestroom类和tempGuestroom对象,调用结构函数,输入客房房间编号、房间类型、定房日期、房间价格、房间内容及个人入住使用期,经过Insert函数实现。voidAddtheGuestroom(tList<cGuestroom>*tListMedic)//输入客房函数{cGuestroomtempGuestroom;//定义临时客房 cout<<"下面开始添加客房信息\n"; cout<<"请输入入住客房编号:"; cin>>tempGuestroom.ID;//读入客房编号 cout<<"请输入客房类型:"; cin>>tempGuestroom.Type;//读入客房类型 cout<<"请输入客人定房日期:"; cin>>tempGuestroom.Book;//读入定房日期 cout<<"请输入客房价格:"; cin>>tempGuestroom.Price;//读入价格 cout<<"请输入客房关键内容:"; cin>>tempGuestroom.Function;//读入关键内容 cout<<"请输入客房入住使用期:"; cin>>tempGuestroom.StayTime;//读入入住使用期 tempGuestroom.flag=true; tListMedic->Insert(tempGuestroom); cout<<"添加成功!\n"; system("pause"); system("cls");}(3)信息删除删除客房信息,按要求提醒输入要删除客房房间编号,定义一个指向链表第一个节点指针p。假如指针创建成功,开始用while和if语句实现p指向节点客房编号和存在客房编号比较。假如相同,输出该客房信息并删除;假如没有相同,提醒没有所查询房间。voidDeletetheGuestroom(tList<cGuestroom>*tListMedic)//删除客房信息{charid[BUFSIZE]; cout<<"\n请输入你要查找客房编号:"; cin>>id;//读取客房编号 boolflag=false; intcount=0;cNode<cGuestroom>*p; p=tListMedic->head->next; while(p) {if(strcmp(p->data.ID,id)==0&&p->data.flag) {count++; flag=true; break;} p=p->next;} if(flag==false)cout<<"对不起,你所查找客房延长了住房日期!\n";//假如不能删 else//假如能删 {count--; cout<<"找到了,该客房原始信息是:\n"; cout<<"\n\n客房编号:"<<(p->data).ID<<"\t客房类型:"<<(p->data).Type<<"\n\t\t定房日期:"<<(p->data).Book<<"\n\t\t价格:"<<(p->data).Price; cout<<"\n\t\t客房关键内容:"<<(p->data).Function<<"\n\t\t入住使用期:"<<(p->data).StayTime; cout<<endl; (p->data).flag=false; cout<<"该客房信息删除成功!\n";} cout<<endl; system("pause"); system("cls"); return;}(4)信息修改按提醒输入要修改客房客房编号,定义一个指向链表第一个节点指针p。假如指针创建成功,开始用while和if语句实现p指向节点客房编号和存在客房编号比较。假如相同,提醒输入房间各个信息;假如没有相同,提醒没有所查询客房。voidModifytheGuestroom(tList<cGuestroom>*tListMedic)//修改客房信息{charid[BUFSIZE]; cout<<"\n请输入你要查找客房编号:";cin>>id;//读取客房编号 boolflag=false;cNode<cGuestroom>*p; p=tListMedic->head->next; while(p) {if(strcmp(p->data.ID,id)==0&&p->data.flag) {flag=true; break;} p=p->next;} if(flag==true) {cout<<"找到了,该客房原始信息是:\n"; cout<<"\n\n客房编号:"<<(p->data).ID<<"\t客房类型:"<<(p->data).Type<<"\n\t\t定房日期:"<<(p->data).Book<<"\n\t\t价格:"<<(p->data).Price; cout<<"\n\t\t客房关键内容:"<<(p->data).Function<<"\n\t\t入住使用期:"<<(p->data).StayTime; cout<<"\n下面开始修改该客房信息:\n"; cGuestroomtempGuestroom;//定义临时客房 cout<<"请输入客房客房编号:"; cin>>tempGuestroom.ID;//读入客房编号 cout<<"请输入客房客房类型:"; cin>>tempGuestroom.Type;//读入客房类型 cout<<"请输入客人定房日期:"; cin>>tempGuestroom.Book;//读入定房日期 cout<<"请输入客房客房价格:"; cin>>tempGuestroom.Price;//读入价格 cout<<"请输入客房客房关键内容:"; cin>>tempGuestroom.Function;//读入客房关键内容 cout<<"请输入客人入住客房使用期:"; cin>>tempGuestroom.StayTime;//读入入住使用期 tempGuestroom.flag=true; p->data=tempGuestroom; cout<<"修改成功!";} cout<<endl; system("pause"); system("cls"); return;}5.测试程序测试是将编制程序投入实际运行前,用手工或编译程序等方法进行测试,修正语法错误和逻辑错误过程。原程序:voidRanktheremainGuestroom(tList<cGuestroom>*tListMedic)//排序剩下客房{cNode<cGuestroom>*p,*q; cGuestroomremainGuestroom; for(p=tListMedic->head->next;p!=NULL;p=p->next) { for(q=p;q!=NULL;q=q->next) {if(p->data.Price>q->data.Price) {remainGuestroom.flag=p->data.flag; strcpy(remainGuestroom.ID,p->data.ID); strcpy(remainGuestroom.Type,p->data.Type); strcpy(remainGuestroom.Book,p->data.Book); strcpy(remainGuestroom.Price,p->data.Price); strcpy(remainGuestroom.Function,p->data.Function); remainGuestroom.StayTime=p->data.StayTime; p->data.flag=q->data.flag; strcpy(p->data.Function,q->data.Function); strcpy(p->data.ID,q->data.ID); strcpy(p->data.Type,q->data.Type); strcpy(p->data.Book,q->data.Book); p->data.StayTime=q->data.StayTime; q->data.flag=remainGuestroom.flag; strcpy(q->data.Function,remainGuestroom.Function); strcpy(q->data.ID,remainGuestroom.ID); strcpy(q->data.Type,remainGuestroom.Type); strcpy(q->data.Book,remainGuestroom.Book); q->data.StayTime=remainGuestroom.StayTime;}}}}编译成功后开始运行,信息录入后,不能在文档中正确排序输出,经Debug调试,发觉,以客人入住天数排序来立即调出空余客房为最好选择。voidRanktheremainGuestroom(tList<cGuestroom>*tListMedic)//排序剩下客房{cNode<cGuestroom>*p,*q; cGuestroomremainGuestroom; for(p=tListMedic->head->next;p!=NULL;p=p->next) {for(q=p;q!=NULL;q=q->next) {if(p->data.StayTime>q->data.StayTime) {remainGuestroom.flag=p->data.flag; strcpy(remainGuestroom.ID,p->data.ID); strcpy(remainGuestroom.Type,p->data.Type); strcpy(remainGuestroom.Book,p->data.Book); strcpy(remainGuestroom.Price,p->data.Price); strcpy(remainGuestroom.Function,p->data.Function); remainGuestroom.StayTime=p->data.StayTime; p->data.flag=q->data.flag; strcpy(p->data.Function,q->data.Function); strcpy(p->data.ID,q->data.ID); strcpy(p->data.Type,q->data.Type); strcpy(p->data.Book,q->data.Book); p->data.StayTime=q->data.StayTime; q->data.flag=remainGuestroom.flag; strcpy(q->data.Function,remainGuestroom.Function); strcpy(q->data.ID,remainGuestroom.ID); strcpy(q->data.Type,remainGuestroom.Type); strcpy(q->data.Book,remainGuestroom.Book); q->data.StayTime=remainGuestroom.StayTime;}} }}6.课题总结和体会此次C++课程设计即使只是短短两个星期,不过却令我体会很多,也学到很多东西。利用C++去设计客房管理,使我加强了对C++认识,也对现代客房基础运作管理有了初步了解。在这次课程设计中,我还知道了程序开发中部分比较关键步骤而且学会了部分没有接触过知识,比如需求分析、类设计和类和类之间关系,UML图形表示方法等。面向对象程序设计作为一门软件设计课程,含有极强实践性,使我加强了灵活应用理论知识能力及面向对象程序设计技能。C++语言相对于C语言来更含有优越性,它不仅兼容C,还有一个很关键特点就是面向对象(具体来讲就是类),另外模板技术频繁引用,也使整个程序看起来更清楚,更有条理化,所以,对模块掌握,在C++学习中是很关键。在此次应用程序设计和创建过程中,我碰到了很多问题,有些是自己没有在教科书中学过,不过却是系统所必需,我经过在网上查找资料、查找书本、请教老师,一步步把这些问题搞懂了,所以,课程设计也培养了我们探索实践能力。总而言之,我认为,我们学习和掌握知识,只有经过实际应用,才能真正了解和掌握,才能愈加好去应用。以前上C++课程,只是零碎被动地接收知识,而不是主动地去吸收渗透,而此次课程设计却让我对编程产生了爱好,习惯独立自主地完成任务,在困难中寻求帮助,加强和同学间互帮互助,相信自己会在以后学习和工作愈加有经验。经过课程设计,我既复习了以前旧知识,又学到了部分新知识;设计增强了我们用所学知识去处理具体问题能力,深入培养了我们独立思索问题和处理问题能力。7.参考文件【1】陈维兴,林小茶.C++面向对象程序设计教程.北京.清华大学出版社,10【2】谭浩强.C语言程序设计.北京:清华大学出版社.,5【3】www.51CTO.com8.源代码//客房管理系统 关键实现功效包含:客房信息录入、修改、删除、剩下客房信息查询、排序、输出。客房信息可写入文件,也可从文件中读取。/*系统登录信息添加信息删除信息修改*/#include<iostream>//指示编译器将文件iostream中代码嵌入到该程序中该指令所在地方usingnamespacestd;#include<fstream> //包含文件流头文件#defineBUFSIZE50classcGuestroom;voidFindTheGuestroom();//查找客房voidFindTheGuestroomById();//根据编号找客房voidFindTheGuestroomByType();//根据类型找客房voidFindTheGuestroomByPrice();//根据价格找客房voidDeleteTheGuestroom();//删除客房voidAddTheGuestroom();//客房添加voidModifyTheGuestroom();//修改客房template<classT>//template:模板,样板classcNode//节点{public: Tdata;cNode*next;};template<classT>classtList{public://定义组员函数 tList(); voidCreate();//创建链表 boolEmpty()const;//判定链表是否为空 voidInsert(constTe);//从尾部插入一个元素 cNode<T>*GetcNode(inti);//返回第i个节点 boolFind(constTe);//在链表中查找某个值 ~tList();//销毁链表,析构cNode<T>*head;//头节点};template<classT>tList<T>::tList()//类组员函数实现{ head=newcNode<T>; head->next=NULL;}template<classT>voidtList<T>::Create(){cNode<T>*p; p=head; p->next=NULL;}template<classT>booltList<T>::Empty()const{ return(head->next==NULL);}template<classT>voidtList<T>::Insert(constTe)//insert:插入{cNode<T>*p,*q; p=head; q=newcNode<T>; q->data=e; while(p->next) { p=p->next; } p->next=q; q->next=NULL;}template<classT>cNode<T>*tList<T>::GetcNode(inti)//返回第i个节点{ intk=0;cNode<T>*p; p=head; while(p&&k<i) { p=p->next; ++k; } returnp;}template<classT>booltList<T>::Find(constTe)//在链表中查找某个值{ boolflag=false;cNode<T>*p; p=head->next; while(p) { if(p->data==e) { flag=true; break; } p=p->next; } returnflag;}template<classT>tList<T>::~tList(){ cNode<T>*p; while(head) { p=head->next; deletehead; head=p; }}classcGuestroom{public: charID[BUFSIZE];//客房编号 charType[BUFSIZE];//客房类型 charBook[BUFSIZE];//提前定房日期 charPrice[BUFSIZE];//客房价格 charFunction[BUFSIZE];//客房关键内容 intStayTime;//入住天数使用期 boolflag;//标志 cGuestroom()//结构函数初始化 { memset(ID,0,BUFSIZE);memset(Type,0,BUFSIZE);memset(Book,0,BUFSIZE);memset(Function,0,BUFSIZE); memset(Price,0,BUFSIZE);StayTime=0.0;flag=false; }//memset:把char类型转换成ASCII值};voidReadData(tList<cGuestroom>*tListGue)//读取数据库{ charbuf[BUFSIZE]; ifstreamifile("Guestroom.txt",ios_base::in); //创建一个输出文件流对象 if(!ifile) { cerr<<"读取时打开文件犯错!"<<endl; } cGuestroomGuestroom; while(ifile.getline(buf,BUFSIZE))//遍历文本,读取数据 { ifile.getline(buf,BUFSIZE); strcpy(Guestroom.ID,buf);//读取客房编号 memset(buf,0,BUFSIZE); ifile.getline(buf,BUFSIZE);//读取客房类型 strcpy(Guestroom.Type,buf); memset(buf,0,BUFSIZE); ifile.getline(buf,BUFSIZE);//读取提前定房日期 strcpy(Guestroom.Book,buf); memset(buf,0,BUFSIZE); ifile.getline(buf,BUFSIZE);//读取价格 strcpy(Guestroom.Price,buf); memset(buf,0,BUFSIZE); ifile.getline(buf,BUFSIZE);//读取客房关键内容 strcpy(Guestroom.Function,buf); memset(buf,0,BUFSIZE); ifile.getline(buf,BUFSIZE);//读取入住使用期 Guestroom.StayTime=atoi(buf); memset(buf,0,BUFSIZE); Guestroom.flag=true; tListGue->Insert(Guestroom); } cout<<"读取数据成功!\n\n"; ifile.close();//关闭文件 return;}voidAddtheGuestroom(tList<cGuestroom>*tListGue)//输入客房函数{ cGuestroomtempGuestroom;//定义临时客房 cout<<"下面开始添加客房信息\n"; cout<<"请输入入住客房编号:"; cin>>tempGuestroom.ID;//读入客房编号 cout<<"请输入客房类型:"; cin>>tempGuestroom.Type;//读入客房类型 cout<<"请输入客人定房日期:"; cin>>tempGuestroom.Book;//读入定房日期 cout<<"请输入客房价格:"; cin>>tempGuestroom.Price;//读入价格 cout<<"请输入客房关键内容:"; cin>>tempGuestroom.Function;//读入关键内容 cout<<"请输入客房入住使用期:"; cin>>tempGuestroom.StayTime;//读入入住使用期 tempGuestroom.flag=true; tListGue->Insert(tempGuestroom); cout<<"添加成功!\n"; system("pause");//pause:停顿,终止 system("cls");}voidSaveData(tList<cGuestroom>*tListGue)//保留数据{ inti=0; ofstreamofile("Guestroom.txt",ios_base::out); //创建一个输入文件流对象 if(!ofile) { cerr<<"保留时打开文件犯错!"<<endl; } cNode<cGuestroom>*p; p=tListGue->head->next; while(p) { //从内存中读取数据,存到外盘 if(p->data.flag) { ofile<<"\n"; ofile<<(p->data).ID<<"\n"; ofile<<(p->data).Type<<"\n"; ofile<<(p->data).Book<<"\n"; ofile<<(p->data).Price<<"\n"; ofile<<(p->data).Function<<"\n"; ofile<<(p->data).StayTime<<"\n"; } p=p->next; } cout<<"保留数据成功!\n"; ofile.close(); system("pause"); system("cls"); return;}voidModifytheGuestroom(tList<cGuestroom>*tListGue)//修改客房信息{ charid[BUFSIZE]; cout<<"\n请输入你要查找客房编号:"; cin>>id;//读取客房编号 boolflag=false;cNode<cGuestroom>*p; p=tListGue->head->next; while(p) { if(strcmp(p->data.ID,id)==0&&p->data.flag) { flag=true; break; } p=p->next; } if(flag==true) {//显示器幕 cout<<"找到了,该客房原始信息是:\n"; cout<<"\n\n客房编号:"<<(p->data).ID<<"\t客房类型:"<<(p->data).Type<<"\n\t\t定房日期:"<<(p->data).Book<<"\n\t\t价格:"<<(p->data).Price; cout<<"\n\t\t客房关键内容:"<<(p->data).Function<<"\n\t\t入住使用期:"<<(p->data).StayTime; cout<<"\n下面开始修改该客房信息:\n"; cGuestroomtempGuestroom;//定义临时客房 cout<<"请输入客房客房编号:"; cin>>tempGuestroom.ID;//读入客房编号 cout<<"请输入客房客房类型:"; cin>>tempGuestroom.Type;//读入客房类型 cout<<"请输入客人定房日期:"; cin>>tempGuestroom.Book;//读入定房日期 cout<<"请输入客房客房价格:"; cin>>tempGuestroom.Price;//读入价格 cout<<"请输入客房客房关键内容:"; cin>>tempGuestroom.Function;//读入客房关键内容 cout<<"请输入客人入住客房使用期:"; cin>>tempGuestroom.StayTime;//读入入住使用期 tempGuestroom.flag=true; p->data=tempGuestroom; cout<<"修改成功!"; } cout<<endl; system("pause"); system("cls"); return;}voidDeletetheGuestroom(tList<cGuestroom>*tListGue)//删除客房信息{ charid[BUFSIZE]; cout<<"\n请输入你要查找客房编号:"; cin>>id;//读取客房编号 boolflag=false; intcount=0;cNode<cGuestroom>*p; p=tListGue->head->next; while(p) { if(strcmp(p->data.ID,id)==0&&p->data.flag) { count++; flag=true; break; } p=p->next; } if(flag==false)cout<<"对不起,你所查找客房延长了住房日期!\n";//假如不能删 else//假如能删 { count--; cout<<"找到了,该客房原始信息是:\n"; cout<<"\n\n客房编号:"<<(p->data).ID<<"\t客房类型:"<<(p->data).Type<<"\n\t\t定房日期:"<<(p->data).Book<<"\n\t\t价格:"<<(p->data).Price; cout<<"\n\t\t客房关键内容:"<<(p->data).Function<<"\n\t\t入住使用期:"<<(p->data).StayTime; cout<<endl; (p->data).flag=false; cout<<"该客房信息删除成功!\n"; } cout<<endl; system("pause"); system("cls"); return;}voidFindtheremainGuestroomById(tList<cGuestroom>*tListGue)//依据客房编号查找{ charid[BUFSIZE]; cout<<"\n请输入你要查找客房编号:"; cin>>id;//读取客房编号 boolflag=false;cNode<cGuestroom>*p; p=tListGue->head->next; while(p) { if(strcmp(p->data.ID,id)==0&&p->data.flag) { flag=true; break; } p=p->next; } if(flag==false)cout<<"对不起,没有该标号客房!\n";//假如找不到 else//假如找到了 { cout<<"\n找到了,该客房信息是:\n"; cout<<"\n\n客房编号:"<<(p->data).ID<<"\t客房类型:"<<(p->data).Type<<"\n\t\t定房日期:"<<(p->data).Book<<"\n\t\t价格:"<<(p->data).Price; cout<<"\n\t\t关键内容:"<<(p->data).Function<<"\n\t\t入住使用期:"<<(p->data).StayTime; } cout<<endl; system("pause"); system("cls");//清屏 return;}voidFindtheremainGuestroomByType(tList<cGuestroom>*tListGue)//依据客房类型查找客房{ chartype[BUFSIZE]; cout<<"\n请输入你要查找客房类型:"; cin>>type;//读取客房类型 boolflag=false;cNode<cGuestroom>*p; p=tListGue->head->next; while(p) { if(strcmp(p->data.Type,type)==0&&p->data.flag) { flag=true; break; } p=p->next; } if(flag==false)cout<<"对不起,没有该类型客房!\n";//假如满了 else//假如找到了 { cout<<"\n找到了,该客房信息是:\n"; cout<<"\n\n客房编号:"<<(p->data).ID<<"\t客房类型:"<<(p->data).Type<<"\n\t\t定房日期:"<<(p->data).Book<<"\n\t\t价格:"<<(p->data).Price; cout<<"\n\t\t客房关键内容:"<<(p->data).Function<<"\n\t\t入住使用期:"<<(p->data).StayTime; } cout<<endl; system("pause"); system("cls"); return;}voidFindtheremainGuestroomByPrice(tList<cGuestroom>*tListGue)//依据价格查找客房{ charprice[BUFSIZE]; cout<<"\n请输入你要查找剩下客房价格:"; cin>>price;//读取价格 boolflag=false;cNode<cGuestroom>*p; p=tListGue->head->next; while(p) { if(strcmp(p->data.Price,price)==0&&p->data.flag) { flag=true; cout<<"\n\n客房编号:"<<(p->data).ID<<"\t客房类型:"<<(p->data).Type<<"\n\t\t定房日期:"<<(p->data).Book<<"\n\t\t价格:"<<(p->data).Price; cout<<"\n\t\t客房关键内容:"<<(p->data).Function<<"\n\t\t入住使用期:"<<(p->data).StayTime; } p=p->next; } if(flag==false)cout<<"对不起,没有你所要求价格客房!\n";//假如找不到 cout<<endl; system("pause"); system("cls"); return;}voidFindtheremainGuestroom(tList<cGuestroom>*tListGue)//查找客房{ system("cls"); while(1) { cout<<"\n\n\n\n"; cout<<"1:按客房编号查询\n\n"; cout<<"2:按客房类型查询\n\n"; cout<<"3:按价格查询\n\n"; cout<<"4:退出查询\n\n"; cout<<"你选择:"; intchoose=0; cin>>choose; switch(choose)//依据用户选择 { case1:FindtheremainGuestroomById(tListGue);//按客房编号查询 break; case2:FindtheremainGuestroomByType(tListGue);//按客房类型查询 break; case3:FindtheremainGuestroomByPrice(tListGue);//按价格查询 break; case4: system("cls"); return;//退出查询 default:break; } } return;}voidRanktheremainGuestroom(tList<cGuestroom>*tListGue)//排序剩下客房{cNode<cGuestroom>*p,*q; cGuestroomremainGuestroom; for(p=tListGue->head->next;p!=NULL;p=p->next) { for(q=p;q!=NULL;q=q->next) { if(p->data.StayTime>q->data.StayTime) { remainGuestroom.flag=p->data.flag; strcpy(remainGuestroom.ID,p->data.ID);//复制 strcpy(remainGuestroom.Type,p->data.Type); strcpy(remainGuestroom.Book,p->data.Book); strcpy(remainGuestroom.Price,p->data.Price); strcpy(remainGuestroom.Function,p->data.Function); remainGuestroom.StayTime=p->data.StayTime; p->data.flag=q->data.flag; strcpy(p->data.Function,q->

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

最新文档

评论

0/150

提交评论