程序语言设计课程设计0911090113郭永涛《酒店住房信息管理系统》.docx
《程序语言设计课程设计0911090113郭永涛《酒店住房信息管理系统》.docx》由会员分享,可在线阅读,更多相关《程序语言设计课程设计0911090113郭永涛《酒店住房信息管理系统》.docx(31页珍藏版)》请在冰点文库上搜索。
程序语言设计课程设计0911090113郭永涛《酒店住房信息管理系统》
一、题目(问题)描述
模拟酒店住房信息管理系统程序,进入系统,目录有登记入住,查询房间入住,查询当前费用,结账退房,帮助说明,关于,保存当前信息,退出系统。
系统中包括各种信息,程序运行结果正确,操作方便,逻辑层次清晰。
如图1解:
图1酒店住房信息管理系统
二、功能分析
通过体验并分析后得出酒店住房信息管理系统主要功能包括:
1.登记入住;
2.查询房间入住;
3.查询当前费用;
4.结账退房;
5.帮助说明;
6.关于;
0.退出.
三、系统设计
1.程序总体结构
程序中由主模块负责协调各功能模块的工作。
进入程序后,根据输入操作,执行相应的读入、查询、排序、增加、删除、显示当前信息、保存、显示平均成绩、退出等功能,并在屏幕上输出。
图2酒店住房信息管理系统的总体结构图
2.界面设计
如图3,下面的Choose:
表示通过选择1、2、3、4、5、6、0等来进入各项功能,从而实现程序对信息的管理。
图3管理信息界面
3.输入方式设计
此程序为dos下程序,因此简化为键盘控制。
1、2、3、4、5、6、0分别表示各项功能。
回车表示确认进入各个程程序;
主页面开始之后,键入:
1.登记入住;
2.查询房间入住;
3.查询当前费用;
4.结账退房;
5.帮助说明;
6.关于;
0.退出.
4.重要数据的数据结构设计
酒店住房信息管理系统结构
typedefstructtmtm;/*structtm命名为tm*/
typedefstructnode/*把struct命名为node*/
{
void*elem;/*无类型指针类型成员*/
structnode*next;/*指针类型成员存放*/
}node_t;/*指针地址*/
typedefstructroom/*房间结构*/
{
introom_number;/*房间号*/
Boolroom_is_used;/*房间已使用*/
Typeroom_kind;/*房间种类*/
charguest_name[20];/*客人姓名*/
charguest_Id[19];/*省份证号*/
doubleroom_price;/*房间价格*/
tm*start_time;/*入住时间*/
tm*end_time;/*退房时间*/
doubletotal_cost;/*合计消费金额*/
}room_t;
5.函数设计
文件中函数的功能如下:
文件名
函数原型
函数功能
“filemenu.c”
voidwelcome()
显示欢迎页面
voidmenu()
主菜单页面
voidlocateposition();
定位光标
voidanimal();
显示一个小动画
voidanimation();
显示另一动画
voidmenu();
菜单项
voidgoodbai()
完成时退出程序
voidpriceinfo()
显示房间价格
四、关键技术、难点及其解决方法
此程序的关键是是否有保存功能,而且是保存把信息保存到文件中后退出程序,当再次进入程序是是否能查找到上次登陆是录入的信息,还有就是当系统要查找、删除信息是如何确定程序中是否有你要查找、删除的信息,来验证系统中是否存在所要的信息。
五、测试方法
1.按键测试。
检查正确的输入时,是否界面正确表现;错误输入时,是否无效。
2.程序运行测试。
正确运行,观察是否异常;运行时中断,程序是否正确退出。
六、总结
通过这次课程设计,使我受到了一次用专业知识、专业技能分析和解决问题的全面系统的锻炼。
对一些基础知识有了更规范的认识。
让我理解到结构化设计相关知识在实际方面的应用的操作,让我更深刻理解的“自顶向下,逐步细化的”思想;模块设计,多个函数并用;代码的重要性及注释的关键性。
使我在综合知识的选用方面,在应用软件开发的基本思想、方法方面,以及在常用编程设计思路技巧的掌握方面都能向前迈了一大步。
此外,我深深地体现到进行软件开发不是一件简单的事情,它需要设计者具有全面的专业知识、缜密的思维、严谨的工作态度以及较高的分析问题、解决问题的能力,而我在很多方面还有欠缺。
最后,我要衷心感谢老师在我的设计过程中给予我的极大帮助,使我能够及时、顺利地完成此次的课程设计。
同时,也要感谢我的指导老师和同学们在本系统的设计过程中给予我的支持和帮助。
附1、使用说明:
1.功能说明.
此程序分为7个选项,分别是登记入住、查询房间入住、查询当前费用、查询当前费用、结账退房、帮助说明、关于、退出等功能,当选1时是进入登记入住功能,2是进入查询房间入住功能,3是进入查询当前费用功能,4是结账退房功能、5是显示帮助说明功能、6是显示关于的信息功能,0是退出系统功能。
2.用户手册.
.显示主菜单后键入数字:
1.登记入住;
2.查询房间入住;
3.查询当前费用;
4.结账退房;
5.帮助说明;
6.关于;
0.退出.
附2、代码清单
*****************************************************************
●“filemenu,c”*
*****************************************************************
#include
#include
#include
#include
#include
#include
#include
#include
#defineROOM_MAX100
#defineTYPE_NUM4
#defineWIDTH80
#defineHIGH25
typedefstructtmtm;
typedefenum{False,True}Bool;
typedefenum{Single,Standard,Vip,President}Type;
typedefstructnode
{
void*elem;
structnode*next;
}node_t;
/*房间结构*/
typedefstructroom
{
introom_number;
Boolroom_is_used;
Typeroom_kind;
charguest_name[20];
charguest_Id[19];
doubleroom_price;
tm*start_time;
tm*end_time;
doubletotal_cost;
}room_t;
voidwelcome();
voidmenu();
voidlocate_position();
voidanimal();
voidanimation(intx);
voidgoodbye();
node_t*list_init();
node_t*list_add(node_t*head,void*elem);
node_t*list_del(node_t*head,node_t*dest);
node_t*list_for_each(node_t*head,
void*(*func)(node_t*head,node_t*cur,void*arg),
void*arg);
node_t*list_reverse(node_t*head);
voidlist_destory(node_t*head);
void*mprint(node_t*head,node_t*cur,void*arg);
void*madd(node_t*head,node_t*cur,void*arg);
void*mdel(node_t*head,node_t*cur,void*arg);
voidroom_add(node_t*head,room_thotal[TYPE_NUM][ROOM_MAX]);
voidroom_del(node_t*head);
voidprice_info();
intincrease_two(inti);
doubleprice_of_room(Typekind);
char*Type_to_string(Typekind);
char*Bool_to_string(Bool_bool_);
room_t*get_first_room(room_thotal[ROOM_MAX],Typekind);
/**
*increase_two
*
*@i要自增的数
*调用一次增加2
*/
intincrease_two(inti)
{
returni+2;
}
/**
*price_of_room
*
*@kind房间类型
*根据房间的类型得到房间的单价
*/
doubleprice_of_room(Typekind)
{
returnpow(2,(int)kind)*100;
}
/**
*定位光标
*@x要定位的列数
*@y要定位的行数
*无返回值
*
*调用API,定位光标位置,比用空格,Tab,回车定位方便许多
*/
voidlocate_position(intx,inty)
{
COORDC;
C.X=x;
C.Y=y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),C);
}
/**
*welcome
*显示欢迎界面(总菜单界面的大部分内容)
*列出用户可进行的操作
*每次任务完成后,再次调用些界面
*/
voidwelcome()
{
intposition=4;
locate_position(25,3);
printf("酒店房间登记与计费管理系统");
locate_position(30,position=increase_two(position));
printf("1:
登记入住");
locate_position(30,position=increase_two(position));
printf("2:
查询房间入住");
locate_position(30,position=increase_two(position));
printf("3:
查询当前费用");
locate_position(30,position=increase_two(position));
printf("4:
结账退房");
locate_position(30,position=increase_two(position));
printf("5:
帮助说明");
locate_position(30,position=increase_two(position));
printf("6:
关于");
locate_position(30,position=increase_two(position));
printf("0:
退出");
locate_position(27,position=increase_two(position));
printf("请选择要办理的业务\n");
}
voidgoodbye()
{
charis_leave='i';
charstr[15]="color0";
charstr_color[2];
intcolor;
time_ttTime;
tm*tBlock;
locate_position(33,10);
printf("确认退出(Y/N)?
");
while(is_leave!
='Y'&&is_leave!
='N')
{
is_leave=kbhit()?
toupper(getch()):
'm';
animal
(1);
animation(6);
animal(18);
animation(19);
animal(20);
animation(21);
animal(22);
animation(23);
strcpy(str,"color0");
color=rand()%8+8;
itoa(color,str_color,16);
strcat(str,str_color);
system(str);
locate_position(29,4);
tTime=time(NULL);
tBlock=localtime(&tTime);
printf("%s%2d:
%02d:
%02d",__DATE__,tBlock->tm_hour,
tBlock->tm_min,tBlock->tm_sec);
locate_position(33,10);
printf("确认退出(Y/N)?
");
_sleep(1000);
}
if(toupper(is_leave)=='Y')
{
locate_position(30,13);
printf("谢谢使用,欢迎下次来访!
");
locate_position(0,0);
getch();
exit(0);
}
else
{
system("cls");
menu();
}
}
/**
*price_info
*
*无参数,显示房间的价格
*/
voidprice_info()
{
intposition=1;
intweidth=20;
printf("\n----------------房间的收费如下------------------");
locate_position(weidth,position=increase_two(position));
printf("1:
%-20s[单间]%10.2f",Type_to_string((Type)0),price_of_room((Type)0));
locate_position(weidth,position=increase_two(position));
printf("2:
%-20s[标准间]%10.2f",Type_to_string((Type)1),price_of_room((Type)1));
locate_position(weidth,position=increase_two(position));
printf("3:
%-20s[VIP房间]%10.2f",Type_to_string((Type)2),price_of_room((Type)2));
locate_position(weidth,position=increase_two(position));
printf("4:
%-20s[总统套房]%10.2f",Type_to_string((Type)3),price_of_room((Type)3));
locate_position(weidth+6,position=increase_two(position));
printf("从中午十二点到第二天中午十二点算一天\n");
locate_position(weidth+12,position=increase_two(position));
printf("不足一天按一天算");
_sleep(3000);
}
/**
*animation
*展示一个小动画
* @x在第几行展示
* 其中随着时间流逝,>>>>>>>不断的向右移动
*/
voidanimation(intx)
{
staticinti=1;
locate_position(1,x);
printf("=============================================================================");
locate_position(i%(WIDTH-5),x);
printf(">>>>>");
i+=3;
if(i>WIDTH-5)
{
i=1;
}
}
/**
*和上面的函数相似,这次是向左
*/
voidanimal(intx)
{
staticinti=74;
locate_position(1,x);
printf("-----------------------------------------------------------------------------");
locate_position(i%(WIDTH-5),x);
printf("<<<<<");
i-=5;
if(i<0)
{
i=WIDTH-6;
}
}
/**
*menu
*菜单项
*
*没有参数,显示菜单界面
*根据不同的选项,进入不同的子模块
*/
voidmenu()
{
intcolor;
inti=0,j;
charstr[15];
charstr_color[2];
charch='m';
time_ttTime;
tm*tBlock;
room_thotal[TYPE_NUM][ROOM_MAX];
node_t*head=list_init();
memset(&hotal,0,sizeof(room_t)*TYPE_NUM*ROOM_MAX);
/*初始化房间信息*/
for(i=0;i{
for(j=0;j{
hotal[i][j].room_number=(i+1)*100+j;
hotal[i][j].room_kind=(Type)i;
hotal[i][j].room_price=price_of_room((Type)i);
if(i*i+j==12)
{
hotal[i][j].room_is_used=True;
list_add(head,&hotal[i][j]);
}
}
}
srand((unsigned)time(NULL));
system("title酒店房间登记与计费管理系统");
while(ch!
='0')
{
ch=kbhit()?
getch():
'm';
switch(ch)
{
case'1':
system("cls");
room_add(head,hotal);
system("pause");
system("cls");
break;
case'2':
system("cls");
printf("\n----------------所有用户信息如下---------------\n\n");
printf("房间号 房间类型 用户名 用户证件 单价\n");
printf("------|----------|-----------|--------------------------|-----------------------\n");
list_for_each(head,mprint,NULL);
system("pause");
system("cls");
break;
case'3':
system("cls");
price_info();
system("pause");
system("cls");
break;
case'4':
system("cls");
room_del(head);
system("pause");
system("cls");
break;
case'5':
system("cls");
printf("
(1)以下是主页:
请按提示输入所需的服务;
(2)输入提示数值:
1,2,3,4,5,6,0!
\n");
break;
case'6':
system("cls");
printf("
(1)系统时间为机器时间,请调整准确时间;
(2)存盘为系统存盘;(3)注意输入格式要有效.\n");
break;
case'0':
system("cls");
goodbye();
break;
default:
break;
}
/*显示动画效果*/
animal(22);
animation
(1);
animation(23);
strcpy(str,"color0");
color=rand()%8+8;
itoa(color,str_color,16);
strcat(str,str_color);
system(str);
welcome();
locate_position(29,4);
tTime=time(NULL);
tBlock=localtime(&tTime);
printf("%s%2d:
%02d:
%02d",__DATE__,tBlock->tm_hour,
tBlock->tm_min,tBlock->tm_sec);
locate_position(48,20);
_sleep(1000);
}
}
/**
*list_init
*初始化链表,这个链表为循环链表,有头结点
*/
node_t*list_init()
{
node_t*head=(node_t*)malloc(sizeof(node_t));
head->elem=NULL;
head->next=head;
returnhead;
}
/**
*list_add
*向链表里面添加结点
*
*@head链表的头结点
*@elem结点中的数据
*此列表为尾插法
*/
node_t*list_add(node_t*head,void*elem)
{
node_t*new_node=(node_t*)malloc(sizeof(node_t));
new_node->elem=elem;
new_node->next=head->