文档详情

C程序设计课程设计酒店客房预订管理源程序.doc

发布:2018-10-06约8.8千字共10页下载文档
文本预览下载声明
#include iostream #include iomanip #include string #include fstream //输入/输出文件流类 using namespace std; const int Maxr=100; //最多的客户 const int Maxb=100; //最多的客房 const int Maxbor=5; //每位客户最多预订五间客房 //客户类,实现对客户的信息的描述 class customer { private: int tag; //删除标记 1:已删 0:未删 int no; //客户编号 char name[10]; //客户姓名 int borbook[Maxbor]; //所订房间 public: customer() {} char *getname() {return name;}//获取姓名 int gettag() {return tag;} //获取删除标记 int getno() {return no;} //获取客户编号 void setname(char na[]) //设置姓名 { strcpy(name,na); } void delbook(){ tag=1; } //设置删除标记 1:已删 0:未删 void addcustomer(int n,char *na) //增加客户 { tag=0; no=n; strcpy(name,na); for(int i=0;iMaxbor;i++) borbook[i]=0; } void borrowbook(int bookid) //预订操作 { for(int i=0;iMaxbor;i++) { if (borbook[i]==0) { borbook[i]=bookid; return; } } } int retbook(int bookid) //退订操作 { for(int i=0;iMaxbor;i++) { if(borbook[i]==bookid) { borbook[i]=0; return 1; } } return 0; } void disp() //读出客户信息 { cout setw(5) no setw(10) name\t 客房编号:[; for(int i=0;iMaxbor;i++) if(borbook[i]!=0) cout borbook[i]; cout ]endl; } }; //客户库类,实现建立客户的个人资料 class RDatabase { private: int top; //客户记录指针 customer read[Maxr]; //客户记录 public: RDatabase() //构造函数,将customer.txt读到read[]中 { customer s; top=-1; fstream file(customer.txt,ios::in); //打开一个输入文件 while (1) { file.read((char *)s,sizeof(s)); if (!file)break; top++; read[top]=s; } file.close(); //关闭 customer.txt } void clear() //删除所有客户信息 { top=-1; } int addcustomer(int n,char *na) //添加客户时先查找是否存在 { customer *p=que
显示全部
相似文档