📄 room.cpp
字号:
#include "Room.h"
#include "Flist.h"
#include "JiHua.h"
#include "iostream.h"
#include "Date.h"
Room::Room(int num1,int count1)
{
roomnum=num1;
count=count1;
for (int i=0;i<7;i++)
{
plan[i]=new Flist();
}
}
Room::~Room()
{
while(pj.GetCount()>0)
{
delete pj.RemoveHead();
}
for (int i=0;i<7;i++)
{
delete plan[i];
}
}
int Room::getroomcount()
{
return count;
}
int Room::getroomnum()
{
return roomnum;
}
void Room::setroomcount(int i)
{
count=i;
}
void Room::setroomnum(int i)
{
roomnum=i;
}
void Room::add(JiHua *p,int day)
{
if(panduan(day,p))
plan[day]->AddTail(p);
}
void Room::deleteplan(JiHua * p)
{
int k=p->getstart()->getday();
POSITION pos=plan[k]->GetHeadPosition();
while(pos)
{
JiHua *jihua=(JiHua *)plan[k]->GetNext(pos);
if(jihua->getend()==p->getend()&&jihua->getstart()&&p->getstart()&&!strcmp(jihua->getlinkman(),p->getlinkman()))
delete p;
}
}
Flist * Room::get(Date * start,Date * end)
{
//Flist * f=this->plan[start->getday()];
Flist * f=this->plan[start->getday()];
return f->select1(start,end);
}
Flist * Room::getplan(int i)
{
return plan[i];
}
int Room::panduan(int day,JiHua *p)
{
int j=0;
POSITION pos=plan[day]->GetHeadPosition();
if(!pos)
return 1;
while(pos)
{
JiHua * jihua=(JiHua *)plan[day]->GetNext(pos);
if(jihua->getstart()->gethour()<p->getstart()->gethour()&&jihua->getend()->gethour()>p->getstart()->gethour()||jihua->getstart()->gethour()<p->getend()->gethour()&&jihua->getend()->gethour()>p->getend()->gethour()||p->getstart()->gethour()<jihua->getstart()->gethour()&&p->getend()->gethour()>jihua->getend()->gethour())
{j=1;
break;}
if(jihua->getstart()->gethour()==jihua->getend()->gethour())
{
if(jihua->getstart()->getmin()<p->getstart()->getmin()&&jihua->getend()->getmin()>jihua->getstart()->getmin()||jihua->getstart()->getmin()<p->getend()->getmin()&&jihua->getend()->getmin()>jihua->getend()->getmin())
{j=1;
break;}
}
else
{
if(p->getstart()->gethour()==jihua->getstart()->gethour()&&jihua->getstart()->getmin()<p->getstart()->getmin())
{j=1;
break;}
else {
if(p->getstart()->gethour()==jihua->getstart()->gethour()&&jihua->getstart()->getmin()>p->getstart()->getmin())
if(p->getend()->gethour()==jihua->getstart()->gethour()&&jihua->getstart()->getmin()<p->getend()->getmin())
{
j=1;
break;
}
else if(p->getend()->gethour()>=jihua->getend()->gethour())
{
j=1;
break;
}
}
if(p->getstart()->gethour()==jihua->getend()->gethour()&&jihua->getstart()->getmin()>p->getstart()->getmin())
{
j=1;
break;
}
if(p->getend()->gethour()==jihua->getend()->gethour()&&p->getend()->getmin()<jihua->getend()->getmin())
{
j=1;
break;
}
if(p->getend()->gethour()==jihua->getstart()->gethour()&&p->getend()->getmin()>jihua->getstart()->getmin())
{
j=1;
break;
}
}
}
if(j==1)
{
cout<<"此会议室已经被占用";
return 0;
}
return 1;
}
int Room::get1(Date * start,Date * end)
{
//Flist * f=this->plan[start->getday()];
Flist * f=this->plan[start->getday()];if(f==NULL)return 1;
return f->select2(start,end);
}
void Room::setplan(int i,Flist *p)
{
plan[i]=p;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -