資源簡介
小學期的功課。模擬一棟大樓四部電梯,調度算法采用先來先服務和順帶服務,同時盡量滿足最短距離服務。每部電梯內的按鈕各自獨立,但大樓總的調度機只有一個。

代碼片段和文件信息
//?Elevator.cpp?:?implementation?file
//
#include?“stdafx.h“
#include?“ElevatorSystem.h“
#include?“ElevatorSystemDlg.h“
#include?“Elevator.h“
#define?F1?336
#define?F2?294
#define?F3?252
#define?F4?210
#define?F5?168
#define?F6?126
#define?F7?84
#define?F8?42
#define?F9?0
#define?up?1
#define?free?0
#define?down?-1
#ifdef?_DEBUG
#define?new?DEBUG_NEW
#undef?THIS_FILE
static?char?THIS_FILE[]?=?__FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
//?CElevator?dialog
CElevator::CElevator(CWnd*?pParent?/*=NULL*/)
:?CDialog(CElevator::IDD?pParent)
{
//{{AFX_DATA_INIT(CElevator)
//?NOTE:?the?ClassWizard?will?add?member?initialization?here
//}}AFX_DATA_INIT
m_rect=CRect(71336162378);
nowfloor=F1;
stop=F1;
head=NULL;
tail=NULL;
state=free;
request=free;
flag=0;
station=NULL;
signal=1;
}
void?CElevator::DoDataExchange(CDataExchange*?pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CElevator)
//?NOTE:?the?ClassWizard?will?add?DDX?and?DDV?calls?here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CElevator?CDialog)
//{{AFX_MSG_MAP(CElevator)
ON_WM_PAINT()
ON_WM_TIMER()
ON_BN_CLICKED(IDC_BUTTON2?On1)
ON_BN_CLICKED(IDC_BUTTON3?On2)
ON_BN_CLICKED(IDC_BUTTON4?On3)
ON_BN_CLICKED(IDC_BUTTON5?On4)
ON_BN_CLICKED(IDC_BUTTON6?On5)
ON_BN_CLICKED(IDC_BUTTON7?On6)
ON_BN_CLICKED(IDC_BUTTON8?On7)
ON_BN_CLICKED(IDC_BUTTON9?On8)
ON_BN_CLICKED(IDC_BUTTON10?On9)
ON_BN_CLICKED(IDC_BUTTON11?OnGO)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
//?CElevator?message?handlers
void?CElevator::OnPaint()?
{
????CPaintDC?dc(this);?//?device?context?for?painting
????CDialog::OnPaint();
CBrush?brushBlue(RGB(160180220));
CBrush?brushblack(RGB(000));
dc.Selectobject(&brushblack);
dc.Rectangle(CRect(710162376));
dc.Selectobject(&brushBlue);
dc.Rectangle(m_rect);
//?TODO:?Add?your?message?handler?code?here
//?Do?not?call?CDialog::OnPaint()?for?painting?messages
}
//DEL?void?CElevator::OnLButtonDblClk(UINT?nFlags?CPoint?point)?
//DEL?{
//DEL? //?TODO:?Add?your?message?handler?code?here?and/or?call?default
//DEL? char?buf[100];
//DEL? sprintf(buf“%d%d“point.xpoint.y);
//DEL? MessageBox(buf);
//DEL? CDialog::OnLButtonDblClk(nFlags?point);
//DEL?}
ElevatorTeam?*CElevator::cteam(ElevatorTeam?*headint?floorint?Crequest)
{
??head=new?ElevatorTeam;
??head->dfloor=floor;
??head->request=Crequest;
??if(CElevator::nowfloor>floor)
??{
??head->EDirection=up;
??}
??else?if(CElevator::nowfloor ??{
??head->EDirection=down;
??}
??else
??{
??head->EDirection=free;
??}
??head->next=NULL;
??tail=head;
??state=head->EDirection;
??request=head->request;
??return?head;
}
ElevatorTeam?*CElevator::add(ElevatorTeam?*tailint?floorint?Crequest)
{??ElevatorTeam?*p1;
???p1=new?ElevatorT
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????34361??2009-07-10?14:56??ElevatorSystem\Debug\Elevator.obj
?????文件?????122974??2009-07-10?14:56??ElevatorSystem\Debug\ElevatorSystem.exe
?????文件?????523084??2009-07-10?14:56??ElevatorSystem\Debug\ElevatorSystem.ilk
?????文件??????13465??2009-07-10?14:56??ElevatorSystem\Debug\ElevatorSystem.obj
?????文件??????13445??2009-07-01?11:50??ElevatorSystem\Debug\ElevatorSystem.obj.enc
?????文件??????43520??2009-07-03?10:35??ElevatorSystem\Debug\ElevatorSystem.opt
?????文件????5565172??2009-07-01?10:12??ElevatorSystem\Debug\ElevatorSystem.pch
?????文件?????418816??2009-07-10?14:56??ElevatorSystem\Debug\ElevatorSystem.pdb
?????文件???????5848??2009-07-10?14:56??ElevatorSystem\Debug\ElevatorSystem.res
?????文件??????46072??2009-07-10?14:56??ElevatorSystem\Debug\ElevatorSystemDlg.obj
?????文件?????106066??2009-07-01?10:12??ElevatorSystem\Debug\StdAfx.obj
?????文件?????246784??2009-07-10?14:56??ElevatorSystem\Debug\vc60.idb
?????文件?????389120??2009-07-10?14:56??ElevatorSystem\Debug\vc60.pdb
?????文件??????13296??2009-07-04?10:41??ElevatorSystem\Elevator.cpp
?????文件???????1954??2009-07-09?20:25??ElevatorSystem\Elevator.h
?????文件??????39728??2009-07-10?14:56??ElevatorSystem\ElevatorSystem.aps
?????文件???????2975??2009-07-10?14:56??ElevatorSystem\ElevatorSystem.clw
?????文件???????2175??2009-06-30?14:51??ElevatorSystem\ElevatorSystem.cpp
?????文件???????4549??2009-07-03?17:28??ElevatorSystem\ElevatorSystem.dsp
?????文件????????553??2009-06-30?14:51??ElevatorSystem\ElevatorSystem.dsw
?????文件???????1412??2009-06-30?14:51??ElevatorSystem\ElevatorSystem.h
?????文件??????82944??2009-07-10?14:56??ElevatorSystem\ElevatorSystem.ncb
?????文件??????57856??2009-07-10?14:56??ElevatorSystem\ElevatorSystem.opt
?????文件???????1627??2009-07-10?14:56??ElevatorSystem\ElevatorSystem.plg
?????文件???????7523??2009-07-10?14:56??ElevatorSystem\ElevatorSystem.rc
?????文件??????15793??2009-07-04?10:29??ElevatorSystem\ElevatorSystemDlg.cpp
?????文件???????2183??2009-07-03?21:55??ElevatorSystem\ElevatorSystemDlg.h
?????文件???????2998??2009-07-03?17:24??ElevatorSystem\image.ico
?????文件????????190??2009-07-04?10:29??ElevatorSystem\Lead.h
?????文件?????929844??1998-06-17?00:00??ElevatorSystem\MFC42D.DLL
............此處省略22個文件信息
評論
共有 條評論