宾馆房间管理系统
一、问题描述 设计一个程序实现对宾馆房间的基本管理,可以实现:客房信息的录入功能;客人入住登记、客人退房结算;客房信息浏览功能,浏览全部客户的信息,客房信息和客户信息分别保存于不同文件;客房信息查询,查询空房间情况,实现按房间号查询等。 二、基本要求 (1)使用面向对象编程思想编写开发过程中需要用到的类,比如:至少包含四个类:日 期类,客房类,主要包含客房信息(房号类型,是否有客人等)及相关操作;客人类,主要完 成客户信息(身份证,入住时间,姓名,性别等)的相关操作;管理类实现对客房的管理。 (2)输入和输出可以使用文本文件重定向输入(保存数据为磁盘文件);也可以使用标 准输入输出进行(提交时需要提交TXT格式输入数据)。比如:room.txt 的文件,文件中应包含 20 条以上记录(房间的初始状态),guest.txt 的文本文件,包含 10 条以上客人记录。 在运行程序时自动载入。 (3)基本功能要求具有增、删、改、查。
基本流程图
#include
#include
#include
#include
#include
#include
#define Max 100
using namespace std;
class Data//日期类,记录交易时间
{
public:
Data(){}//缺省构造函数
~Data(){}//析构函数
void SetDate(int year,int month,int day)//接收输入的日期
{
this->year=year;
this->month=month;
this->day=day;
}
int getyear(){
return year;
}
int getmonth(){
return month;
}
int getday(){
return day;
}
private:
int year;
int month;
int day;
};
class Room
{
public:
Room *r[Max];//房间对象指针数组
int Room_count; //记录房间数量
Room(int Number,string Type,double Price,string Whether)//构造函数
{
this->Number=Number;
this->Type=Type;
this->Whether=Whether;
this->Price=Price;
}
int InputNumber() {return Number;}
string InputType(){return Type;}
string InputWhether(){return Whether;}
double InputPrice(){return Price;}
void SetWether(string _state) {Whether=_state;}
void show() {cout
this->Name=Name; this->Id=Id; this->sex=sex; this->number=number;
this->Intime=Intime; this->days=days;
}
int InputNumber(){return number;}
string InputName(){return Name;}
string InputSex(){return sex;}
int InputDays(){return days;}
string InputIntime(){return Intime;}
int InputId(){return Id;}
void show()
{
cout
int n;
system("cls");
cout
string type,Whether;
double price;
int number;
coutnumber;
couttype;
coutprice;
coutWhether;
WriteRoom(new Room(number,type,price,Whether));
}
void Manage::Check_In()//删除房间信息,即入房登记
{
ReadData();
SearchType();
string name,intime,sex,type;
int days,number;
int id;
coutnumber;
coutname;
coutid;
coutsex;
coutintime;
coutdays;
for(i=0;i
WriteGuest(new Guest(number,name,id,sex,intime,days));
r[i]->SetWether("有");
WriteData(1);
cout
if(number==g[i]->InputNumber())
{
return i;
}
}
}
void Manage::Check_Out()
{
int x=Payment();
ReadData();
for(i=0;i
r[i]->SetWether("无");
cout
case 1:
for(i=0; i
cout
cout
cout
switch(n)
{
case 1:
{
ofstream Rout("room.txt",ios::trunc); //用二进制的方法打开顾客文件 ,覆盖掉之前的所有信息重新写入
for(i=0; i
WriteRoom(r[i]);//调用构造函数来创建顾客信息
}
}
Rout.close(); break;}
case 2:{
ofstream Gout("guest.txt",ios::trunc); //用二进制的方法打开顾客文件 ,覆盖掉之前的所有信息重新写入
for(i=0; i
WriteGuest(g[i]);//调用构造函数来创建顾客信息
}
}
Gout.close();break;}
}
}
void Manage::WriteRoom(Room *r)//储存单个信息
{
ofstream Rout("room.txt",ios::app);//打开房间文件,追加读写,不会覆盖掉之前的所有信息
Rout
ReadData();
for(i=0;i
r[i]->show();}
}
}
void Manage::SearchNumber()
{
ReadData();
int number,n;
coutnumber;
for(i=0;i
if(g[i]->InputNumber()==number)
g[i]->show();
}
}
int main()
{
Manage M;
int n;
while(1)
{
system("cls");
cout |