第五组酒店客房预订管理系统的设计与实现源代码(可编辑修改word版)

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
{
return &book[i];
}
return NULL;
}
Book *query(string bname)
{
for (int i=0;i<=top;i++)
if (book[i].getname()==bname&&book[i].gettag()==0)
}
};
//客户库类,实现建立客户的个人资料class RDatabase
{
private:
inttop;//客户记录指针
customerread[Maxr];//客户记录public:
RDatabase()//构造函数,将customer.txt读到read[]中
{
customer s; top=-1;
cout<<"删除成功!"<<endl; break;
default:cout<<"正在返回主界面...";system("cls");break;
}
}
}
//客房类,实现对客房的描述class Book
{
private:
inttag;//删除标记1:已删0:未删
int no;//客房编号
charname[20];//客房描述
}
};
//客房库类,实现对客房的管理,如查找、删除等class BDatabase
{
private:
inttop;//客房记录指针
Book book[Maxb];//客房记录public:
BDatabase()//构造函数,将book.txt读到book[]中
{
Book b;
top=-1;
fstream file("book.txt",ios::in); while (1)
if (r==NULL)
{
cout <<"该客户不存在" <<endl;break;
}
case '4':
r->delbook();
cout<<"删除成功!"<<endl; break;
char cho;
cout<<"请选择查找方式:"<<endl;
cout<<"1.按客户编号查找,2.按客户姓名查找"; cin>>cho;
cout<<"输入客户名字:"; cin >> rname; r=query(rname);
if (r==NULL)
{
cout<<"该客户不存在"<<endl; break;
}
}
r->display(); break;
case '5':
display(); break;
case '6':
clear();
constintMaxbor=10;//每位客户最多预订十间客房
//person类class person
{
public:
char name[20]; char ID[18];
char*getname(){returnname;}//获取姓名char *getID(){returnID;}//获取身份证号voidsetID(charI[])//设置身份证号
//获取客房编号
//获取删除标记
//设置客房描述
{
strcpy(name,na);
}
void delbook(){ tag=1;}
//删除客房
void addbook(int n,char *na)
//增加客房
{
tag=0;
no=n;
strcpy(name,na);
onshelf=1;
}
int borrowbook()
}
customer*query(string name)//按name查找
{
for (int i=0;i<=top;i++)
if (read[i].getname()==name&&read[i].gettag()==0)
{
return &read[i];
}
return NULL;
}
voiddisplay()//输出所有客户信息
#include <iostream> #include <iomanip> #include <string> #include <fstream>
#include"conio.h"//输入/输出文件流类using namespacestd;
constintMaxr=100;//最多的客户
constintMaxb=100;//最多的客房
cout << "输入客户身份证号:"; cin >> rID;
addcustomer (customerid,rname,rID); break;
case '2':
cout << "输入客户编号:"; cin >> customerid; r=query(customerid);
if (r==NULL)
int borbook[Maxbor];//所订房间public:
customer() {}
int gettag(){returntag;}//获取删除标记
voiddelbook(){tag=1;}//设置删除标记1:已删0:未删int getnum(){return num;}//获取客户编号
void addcustomer(int n,char*na,char *I)//增加客户
intonshelf;//是否预订1:空房2:已预订public:
Book(){}
char *getname() { returnname; }//获取姓名
int getno(){ return no; } int gettag(){ return tag;}
void setname(charna[])
while (choice!='0')
{
cout<<endl<<setw(40)<<"客


息"<<endl;
cout<<endl<<setw(28)<<"1
"<<"新
增"<<endl;
cout<<endl<<setw(28)<<"2
"<<"更
改"<<endl;
cout<<endl<<setw(28)<<"3
fstreamfile("customer.txt",ios::in);//打开一个输入文件while(1)
{
file.read((char *)&s,sizeof(s)); if (!file)break;
top++; read[top]=s;
}
file.close();//关闭customer.txt
{
top++; book[top].addbook(n,na); return 1;
}
return 0;
}
Book *query(intbookid)//查找客房
{
for (int i=0;i<=top;i++)
if (book[i].getno()==bookid &&book[i].gettag()==0)
{
strcpy(ID,I);
}
voidsetname(charna[])//设置姓名
{
strcpy(name,na);
}
};
//客户类公有继承了person类,实现对客户的信息的描述class customer:public person
{
private:
intnum;//客户编号
inttag;//删除标记1:已删0:未删
{
file.read((char *)&b,sizeof(b)); if (!file) break;
top++; book[top]=b;
}
file.close();
}
voidclear()//全删
{
top=-1;
}
int addbook(intn,char *na)//增加客房
{
Book*p=query(n);if (NULL==p)
//预订操作
{
if (onshelf==1)
{
onshelf=0;
return 1;
}
return 0;
}
void retbook()
//退订操作
{
onshelf=1;
}
void disp()
//输出客房
{
cout<<"客

编号:"<<no<<setw(15)<<"客 房 描述:"<<name
<<setw(15)<<(onshelf==1?"空房":"已预订")<<endl;
}
return 0;
}
customer*query(int customerid)//按编号查找
{
for (int i=0;i<=top;i++)
if (read[i].getnum()==customerid&&read[i].gettag()==0)
{
return &read[i];
}
return NULL;
}
voidclear()//删除所有客户信息
{
top=-1;
}
int addcustomer(int n,char*na,char*I)//添加客户时先查找是否存在
{
customer *p=query(n); if (p==NULL)
{
top++; read[top].addcustomer(n,na,I); return 1;
{
borbook[i]=bookid; return;
}
}
}
intretbook(int bookid)//退订操作
{
for(int i=0;i<Maxbor;i++)
{
if(borbook[i]==bookid)
{
borbook[i]=0; return 1;
}
}
return 0;
}
voiddisplay()//读出客户信息
{
tag=0; num=n;
strcpy(name,na); strcpy(ID,I);
for(int i=0;i<Maxbor;i++) borbook[i]=0;
}
void borrowbook(int bookid)//预订操作
{
for(int i=0;i<Maxbor;i++)
{
if (borbook[i]==0)
Baidu Nhomakorabea"<<"返
回"<<endl;
cin>>choice;
system("cls");
switch (choice)
{
case '1':
cout <<"请输入客户信息:"<<endl;
cout << "输入客户编号:"; cin >> customerid;
cout << "输入客户姓名:"; cin >> rname;
{
cout << "该客户不存在"<<endl; break;
}
cout << "输入新的客户姓名:"; cin >> rname;
r->setname(rname);
cout<<"输入新的身份证号码:"; cin>>rID;
r->setID (rID); break;
case '3':
cout << "输入客户编号:"; cin >> customerid; r=query(customerid);
if (read[i].gettag()==0)
file.write((char *)&read[i],sizeof(read[i])); file.close();
}
};
void RDatabase::customerdata()
{
char choice; char rsex[10]; char rname[20]; int customerid; char rID[18]; customer *r; system("cls");
{
for (int i=0;i<=top;i++) if(read[i].gettag()==0)
read[i].display();
}
voidcustomerdata();//客户库维护
~RDatabase()//析构函数,将read[]写到customer.txt文件中
{
fstream file("customer.txt",ios::out); for (int i=0;i<=top;i++)
system("cls"); switch (cho)
{
case '1':
cout << "输入客户编号:"; cin >> customerid; r=query(customerid);
if (r==NULL)
{
cout <<"该客户不存在"<< endl; break;
}
break; case'2':
"<<"删
除"<<endl;
cout<<endl<<setw(28)<<"4
"<<"查
找"<<endl;
cout<<endl<<setw(28)<<"5
"<<"显
示"<<endl;
cout<<endl<<setw(28)<<"6
"<<"全
删"<<endl;
cout<<endl<<setw(28)<<"0
{
cout<<"客户编号:"<<num<<setw(15)<<"姓名:"<<name<<setw(15)<<"身份证号:" << ID<<setw(15)<<"客房编号:[";
for(int i=0;i<Maxbor;i++) if(borbook[i]!=0)
cout <<"#"<< borbook[i]<<" "; cout << "]"<<endl;
相关文档
最新文档