面向对象程序设计酒店客房预订系统解析.doc
文本预览下载声明
面向对象程序课程设计
题目:酒店客房预订系统
需求分析:设计一个小型的快捷式酒店客房预订系统,实现对不同类型的客房进行预定,退房以及费用的计算。
系统结构图:
类的设计:
类date:获取当前时间
-d -m -y +date +add 类hotel:
-x; -room[10]; -SR; -KR; -DR; -name[10]; -ID[20]; -Pay_s; -Pay_k; - Pay_d; -time; -income; +Hotel +choose +void in +book +cancel +display
程序代码与说明:
date.h
#includeiostream
#includecstdio
#includectime
#includecstdlib
#includeWindows.h
using namespace std;
class date{
private:
int d, m, y;
public:
date();
void add();
};
head.h
#includedate.h
#includeiostream
#includefstream
#includecstdio
#includectime
#includecstdlib
#includeWindows.h
using namespace std;
class Hotel{
private:
int x; //选择定/退房
int room[10]; //记录房间预定情况
int SR; //标准间余量standard room
int KR; //大床间余量king room
int DR; //豪华间余量deluxe room
char name[10]; //登记客户姓名
char ID[20]; //登记客户身份证号
double Pay_s; //标准间支付费用
double Pay_k; //大床房支付费用
double Pay_d; //豪华间支付费用
double time; //入住天数
double income; //总收入
public:
Hotel(int a,int b,int c);
void choose(int c,int t); // c(choose):记录订房或退房, t(type):记录所选房间类型
void book(int t); //订房
void cancel(int t); //退房
void display(); //输出房间余量表
void in();
};
date.cpp
#includedate.h
#includecstdio
date::date()
{
time_t now;
time(now);
struct tm *t_now;
t_now = localtime(now);
y = t_now - tm_year + 1900;
m = t_now - tm_mon + 1;
d = t_now - tm_mday;
}
void date::add()
{ cout 今天是 y年m月d日endl;
cout 欢迎您的光临!endl;
cout 价格表:endl;
cout 标准间:150RMB/dendl;
cout 大床间:200RMB/dendl;
cout 豪华间:500RMB/dendl;
}
hotel.cpp
#includehead.h
Hotel::Hotel(int a,int b,int c){
SR=a;KR=b;DR=c;
};
void Hotel::choose(int c,int t){
x=c;
if(c==1) //订房
book(t);
if(c==2) //退房
cancel(t);
}
void Hotel::book(int t){
int m,c=0;
double time=0;
double Pay_s=0;
double Pay_k=0;
double Pay_d=0;
double Pay=0;
显示全部