李志刚S07059会议室管理.docx
《李志刚S07059会议室管理.docx》由会员分享,可在线阅读,更多相关《李志刚S07059会议室管理.docx(31页珍藏版)》请在冰豆网上搜索。
李志刚S07059会议室管理
1题目描述(三号字、黑体)
作业题目:
会议室管理
系统需求如下:
1.提供会议室使用计划的输入、修改、转储到文件和从文件导入的功能
2.提供条件查询功能:
1.根据给定的日期和房间号,查询使用计划
2.根据给定的日期和人数,查找可用的会议室
3.系统应该维护会议室使用计划,包括会议所在房间号码、日期、时间段、联系人姓名
4.系统应该支持会议室信息的输入、添加和保存;
包括会议室房间号码、可容纳人数
完成的功能:
1.会议室的输入、修改、添加、保存
2.会议室使用计划添加、修改、转存以及导入
3.通过条件查询会议室使用计划并且列表显示(条件:
日期、房间号)
4.通过条件查询可用的会议室并且列表显示(条件:
日期、人数)
满足的约束条件:
1.会议室的房间号必须是int范围内的数字
2.会议室最多容纳的人数必须必须是int范围内的数字
数据及获取来源:
1.人工输入
2.从文件读取
分析:
会议室是实体型对象
会议室管理是管理类对象
计划是实体型对象
所有计划是管理类对象
有关联关系
有整体部分关系
没有一般和特殊的关系,没有多态
2类设计(三号字、黑体)
2.1类图
2.2类声明
图一整体的代码结构
图2会议室基类
图3小型会议类声明
图4中型会议室类声明
图5大型会议室类声明
#pragmaonce
//包含要使用类的头文件
#include"MeetingRoom.h"
#include"MeetingRoomBig.h"
#include"MeetingRoomMiddle.h"
#include"MeetingRoomSmall.h"
//会议室管理类
classMeetingRoomManage
{
public:
//管理类自身
//staticMeetingRoomManage*m_MeetingRoomManage;
public:
//所有会议室的列表
CObArraym_roomList;
MeetingRoomManage();
~MeetingRoomManage();
/*
添加一个会议室
room一个会议室对象
reruan:
0表示更新失败1更新成功
*/
intaddRoom(MeetingRoomroom);
/*修改一个会议室信息
oldroom是要修改的会议室对象
size修改为size类型
reruan:
0表示更新失败1更新成功
*/
intupdateRoom(MeetingRoomoldroom,char*size);
/*
查找一个会议室
roomID会议室的编号
*/
MeetingRoom*query(introomID);
/*
更新所有的会议室信息
改变会议室相应类型所对应的最多容纳人数之后
size会议室的类型
maxPeo对应的最多容纳的人数
reruan:
0表示更新失败1更新成功
*/
intupdateRoomAll(char*size,intmaxPeo);
/*
获取的该类的实例化对象
*/
/*staticMeetingRoomManage*MeetingRoomManage:
:
getInstance()
{
if(m_MeetingRoomManage==NULL)
{
m_MeetingRoomManage=newMeetingRoomManage();
returnm_MeetingRoomManage;
}
returnm_MeetingRoomManage;
}
*/
};
//MeetingRoomManage*MeetingRoomManage:
:
m_MeetingRoomManage=NULL;
图6会议室管理类声明
图7计划类声明
图8计划管理类声明
图9文件操作类声明
3功能实现(三号字、黑体)
3.1菜单
1.主界面查询功能
2.使用计划
3.会议室一些功能
4.文件保存读取功能
3.2功能1
UML时序图
附录:
程序源代码
会议室类
#include"stdafx.h"
#include"MeetingRoom.h"
MeetingRoom:
:
MeetingRoom()
{
}
MeetingRoom:
:
MeetingRoom(introomID)
{
this->roomID=roomID;
}
MeetingRoom:
:
~MeetingRoom()
{
}
intMeetingRoom:
:
getRoomID(int&roomID)
{
returnroomID=this->roomID;
}
小型会议室类:
#include"stdafx.h"
#include"MeetingRoomSmall.h"
MeetingRoomSmall:
:
MeetingRoomSmall()
{
}
MeetingRoomSmall:
:
MeetingRoomSmall(introomID,char*size,intmaxPeople):
MeetingRoom(roomID)
{
this->size=size;
this->maxPeople=maxPeople;
}
MeetingRoomSmall:
:
~MeetingRoomSmall()
{
}
voidMeetingRoomSmall:
:
setSize(char*size)
{
this->size=size;
}
voidMeetingRoomSmall:
:
getSize(char*&size)
{
size=(this->size);
}
voidMeetingRoomSmall:
:
setMaxPeople(intmax)
{
this->maxPeople=max;
}
voidMeetingRoomSmall:
:
getMaxPeople(int&maxPeople)
{
maxPeople=this->maxPeople;
}
中型会议室类
#include"stdafx.h"
#include"MeetingRoomMiddle.h"
MeetingRoomMiddle:
:
MeetingRoomMiddle()
{
}
MeetingRoomMiddle:
:
MeetingRoomMiddle(introomID,char*size,intmaxPeople)
{
}
MeetingRoomMiddle:
:
~MeetingRoomMiddle()
{
}
voidMeetingRoomMiddle:
:
setSize(char*size)
{
this->size=size;
}
voidMeetingRoomMiddle:
:
getSize(char*&size)
{
size=(this->size);
}
voidMeetingRoomMiddle:
:
setMaxPeople(intmax)
{
this->maxPeople=max;
}
voidMeetingRoomMiddle:
:
getMaxPeople(int&maxPeople)
{
maxPeople=this->maxPeople;
}
大型会议室类
#include"stdafx.h"
#include"MeetingRoomBig.h"
MeetingRoomBig:
:
MeetingRoomBig()
{
}
MeetingRoomBig:
:
MeetingRoomBig(introomID,char*size,intmaxPeople):
MeetingRoom(roomID)
{
this->size=size;
this->maxPeople=maxPeople;
}
MeetingRoomBig:
:
~MeetingRoomBig()
{
}
voidMeetingRoomBig:
:
setSize(char*size)
{
this->size=size;
}
voidMeetingRoomBig:
:
getSize(char*&size)
{
size=(this->size);
}
voidMeetingRoomBig:
:
setMaxPeople(intmax)
{
this->maxPeople=max;
}
voidMeetingRoomBig:
:
getMaxPeople(int&maxPeople)
{
maxPeople=this->maxPeople;
}
#include"stdafx.h"
#include"MeetingRoomManage.h"
MeetingRoomManage:
:
MeetingRoomManage()
{
}
MeetingRoomManage:
:
~MeetingRoomManage()
{
//deletem_MeetingRoomManage;
}
intMeetingRoomManage:
:
addRoom(MeetingRoomroom)
{
//添加一个对象到对象数组
if(this->m_roomList.Add(&room))
return1;
return0;
}
intMeetingRoomManage:
:
updateRoom(MeetingRoomoldroom,char*size)
{
oldroom.setSize(size);
return1;
}
MeetingRoom*MeetingRoomManage:
:
query(introomID)
{
//获取数组的长度
intcount=this->m_roomList.GetSize();
//for循环查找
inti;inttemp=0;
for(i=0;i{
((MeetingRoom*)(this->m_roomList.GetAt(i)))->getRoomID(temp);
if(roomID==temp)
return((MeetingRoom*)(this->m_roomList.GetAt(i)));
}
returnNULL;
}
intMeetingRoomManage:
:
updateRoomAll(char*size,intmaxPeo)
{
//获取数组的长度
intcount=this->m_roomList.GetSize();
//for循环查找
inti;
chara[10];
char*temp=a;
for(i=0;i{
//找到相应的类型则改变其最多容纳人数的属性
((MeetingRoom*)(this->m_roomList.GetAt(i)))->getSize(temp);
if(!
strcmp(size,temp))
{
((MeetingRoom*)(this->m_roomList.GetAt(i)))->setMaxPeople(maxPeo);
}
return1;
}
return0;
}
计划类:
#include"stdafx.h"
#include"Plan.h"
Plan:
:
Plan()
{
}
Plan:
:
Plan(intm_planID,intm_roomID,char*m_date,intm_timeh,char*m_user)
{
this->m_roomID=m_roomID;
this->m_date=m_date;
this->m_timeh=m_timeh;
this->m_user=m_user;
}
Plan:
:
~Plan()
{
}
voidPlan:
:
setM_planID(intm_planID)
{
this->m_planID=m_planID;
}
voidPlan:
:
setM_roomID(intm_roomID)
{
this->m_roomID=m_roomID;
}
voidPlan:
:
setM_date(char*m_date)
{
this->m_date=m_date;
}
voidPlan:
:
setM_timeh(intm_timeh)
{
this->m_timeh=m_timeh;
}
voidPlan:
:
setM_user(char*m_user)
{
this->m_user=m_user;
}
voidPlan:
:
getM_planID(int&m_planID)
{
m_planID=this->m_planID;
}
voidPlan:
:
getM_roomID(int&m_roomID)
{
m_roomID=this->m_roomID;
}
voidPlan:
:
getM_date(char*&m_date)
{
m_date=this->m_date;
}
voidPlan:
:
getM_timeh(int&m_timeh)
{
m_timeh=this->m_timeh;
}
voidPlan:
:
getM_user(char*&m_user)
{
m_user=this->m_user;
}
计划管理类
#include"stdafx.h"
#include"PlanManage.h"
PlanManage:
:
PlanManage()
{
}
PlanManage:
:
~PlanManage()
{
}
/*
根据给定的日期和房间号,查询使用计划
*/
voidPlanManage:
:
query_1(char*date,introomID)
{
//先清空数组
this->query_1_List.RemoveAll();
//取得总共的计划条数
intcount=this->m_planList.GetSize();
//存放plan记录
Plan*plan;
//fou循环查找符合条件的记录放到数组中
inti;
for(i=0;i{
plan=(Plan*)this->m_planList.GetAt(i);//取出一条计划
char*m_date;plan->getM_date(m_date);//得到该计划的日期
intm_roomID;plan->getM_roomID(m_roomID);//获取该计划的会议室编号
if(!
strcmp(m_date,date))//日期一样
{
if(m_roomID==roomID)//会议室编号一样
{
this->query_1_List.Add(plan);//符合俩个条件加入结果组
}
}
}
}
/*
根据给定的日期和人数,查找可用的会议室
*/
voidPlanManage:
:
query_2(char*date,intmaxPeople)
{
//先清空数组
this->query_2_List.RemoveAll();
//第一步现寻找所有符合计划的会议室
//所有会议室的个数
intcount=m_roomManage.m_roomList.GetSize();
inti;MeetingRoom*room;
for(i=0;i{
room=(MeetingRoom*)m_roomManage.m_roomList.GetAt(i);//取出一个会议室
intm_maxPeople;room->getMaxPeople(m_maxPeople);//获取会议室的最大容纳人数
if(m_maxPeople>=maxPeople)
{
this->query_2_List.Add(room);
}
}
//第二步把在给定日期内已经被预约的会议室去掉
//双层for循环
for(i=0;iquery_2_List.GetSize();i++)
{
//存放会议室指针
MeetingRoom*room=(MeetingRoom*)this->query_2_List.GetAt(i);
introomID;room->getRoomID(roomID);//获取该计划的会议室编号
Plan*plan;
//取得总共的计划条数
intcount=this->m_planList.GetSize();
//存放plan记录
intj;
//fou循环查找已经预约过的的会议室(在指定日期)
for(j=0;j{
plan=(Plan*)this->m_planList.GetAt(j);//取出一条计划
char*m_date;plan->getM_date(m_date);//得到该计划的日期
intm_roomID;plan->getM_roomID(m_roomID);//获取该计划的会议室编号
if(!
strcmp(m_date,date))//日期一样
{
if(m_roomID==roomID)//已经在计划中的会议室编号去掉
{
this->query_2_List.RemoveAt(i);//去掉已经在计划中的会议室
}
}
}
}
}
/*
添加使用计划
*/
intPlanManage:
:
addPlan(Planplan)
{
plan.setM_planID(this->m_planID);
if(this->m_planList.Add(&plan))
return1;
return0;
}
/*
修改使用计划
//把旧的计划删掉把新的计划添加进去
*/
intPlanManage:
:
updatePlan(PlanoldPlan,PlannewPlan)
{
//取得总共的计划条数
intcount=this->m_planList.GetSize();
//存放plan记录
intj;Plan*plan;
//fou循环查找已经预约过的的会议室(在指定日期)
for(j=0;j{
plan=(Plan*)this->m_planList.GetAt(j);//取出一条计划
intm_planID;plan->getM_planID(m_planID);//得到该计划的ID
intm_old_planID;oldPlan.getM_planID(m_old_planID);//得到旧的计划的ID
if(m_planID==m_old_planID)//找到old计划
{
this->m_planList.RemoveAt(j);//去掉旧的计划
this->m_planList.Add(&newPlan);//添加新的计划
return1;
}
}
return0;
}
文件类:
#include"stdafx.h"
#include"FileOp.h"
FileOp:
:
FileOp()
{
}
FileOp:
:
~FileOp()
{
}
intFileOp:
:
writeFile(CObArrayplanList,CObArrayroomList)
{
//即将推出的功能
//老师由于时间有限这个功能没有实现请原谅
return0;
}
intFileOp:
:
readFile(CObArray&planList,CObArray&roomList)
{
//即将推出的功能
//老师由于时间有限这个功能没有实现请原谅
return0;
}