(论文)数据结构课程设计最新优秀毕业论文资料搜集呕血奉献_第1页
(论文)数据结构课程设计最新优秀毕业论文资料搜集呕血奉献_第2页
(论文)数据结构课程设计最新优秀毕业论文资料搜集呕血奉献_第3页
(论文)数据结构课程设计最新优秀毕业论文资料搜集呕血奉献_第4页
(论文)数据结构课程设计最新优秀毕业论文资料搜集呕血奉献_第5页
已阅读5页,还剩83页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

Harbin Institute of Technology at Weihai数据结构课程设计报告设计题目: 电梯模拟系统 院 系: 计算机科学与技术学院 班 级: 学 号: 设 计 者: 哈尔滨工业大学(威海)二零零七年七月I哈尔滨工业大学(威海)计算机学院数据结构课程设计验收及成绩评定表(项目组)项目名称电梯模拟系统职责学 号姓 名主 要 分 工组长安文龙050410126全部成员成员成员设计开始日期2007-7-3项目完成日期2007-7-15文 档 评 审 成 绩 (共50分)评审项目评审内容成绩标准评审成绩项目名称课题是否从实际出发,是否具有创意等20文档格式文档格式是否规范;文字是否规范;图表是否规范;术语是否准确等10分文档质量程序设计思想与整体框架是否清晰等20分文档总体评价总成绩程 序 功 能 完 备 性 评 审 成 绩 (共 50 分)评审项目评 审 内 容成绩标准评审成绩程序运行状况程序是否能正常运行;是否出现死锁;是否遇到错误而中止运行10分程序正确性对于给定的输入数据,是否能得到正确的输出结果15分程序与文档的一致性程序与各种文档的内容是否一致5 分程序的代码量程序代码量的大小10分实现方法图形界面或命令行界面,美观程度5分实现语言面向过程或面向对象5分程序总体评价总成绩哈尔滨工业大学(威海)课程设计任务书 姓 名: 安文龙 学 号:050410126院(系): 计算机科学与技术学院 专 业:计算机科学与技术学院 任务起止日期:2007 年 7 月 3 日 至 2007年 7 月 15 日 课程设计题目:电梯模拟系统 问题阐述与分析: 电梯是我们日常生活中不可或缺的一种重要工具。电梯的运行是电梯与大楼及各个楼层的使用者互相交互的过程,而相应的电梯模拟就是对这一交互过程进行实际模拟,已达到运载客户的功能。本程序运用时钟控件解决对各个楼层请求的响应顺序问题。本次程序的核心算法是处理电梯在某一时刻的状态、动作以及对下一时刻的状态和动作作出预测和判断。程序的重点在于确定电梯的各个状态以及运行方向,处理各种请求,对每一个动作和状态的时间进行处理。其它的活动体如乘客则相对独立,处理起来更为容易一些。 某7层高的楼,设有载客电梯1部。其具体功能如下:(1) 电梯的运行规则是:可到达每层。(2) 模拟开始时,电梯随机地处于其符合运行规则的任意一层,为空梯。(3) 按下“外请求”按钮,表示用户的申请,电梯将根据申请情况运行。(4) 按下“内请求”按钮,表示用户在电梯内部的操作。(5) 当电梯响应完全部请求后,电梯将自动关门并在终止层等待。(6) 电梯可以随时显示其当前信息,如所在楼层,运动状态等。 工作量:1. 设计可视化操作界面;2. 电梯时钟设计3. 电梯门开关设计4. 乘客请求,电梯响应设计II哈尔滨工业大学(威海)课程设计报告(论文)数据结构课程设计报告软硬件运行环境语言:Delphi运行环境:Delphi 7.0硬件:无要求 问题及难点所在本次程序的难点是处理电梯在某一时刻的状态、动作以及对下一时刻的状态和动作作出预测和判断。程序的重点在于确定电梯的各个状态以及运行方向,处理各种请求,对每一个动作和状态的时间进行处理。其它的活动体如乘客则相对独立,处理起来更为容易一些。由于电梯运行情况比较复杂,所以采用面向对象的编程语言,使程序实现起来比较简单,并且界面也比较容易设计。 算法设计的思想1、初始化初始化电梯基本信息,如运动状态,所在层数,是否收到请求等。 2、响应各请求 响应前先判断电梯对应此时刻的运动状态,若此时处于停留在某一楼层,则先判断目标运动方向是否相同,若相同,则采用就近原则,若目标运动方向不相同,则采用先请求先响应原则。若此时处于运动状态,则要考虑请求是内部请求还是外部请求。总的原则是若有内部请求,则先响应。只有内部请求时,采用最短路程原则。在内部响应进行时,若有外部请求,则要判断其外部请求的运动方向是否与电梯运动方向相同,若相同,则响应外部请求。否则等内部请求响应完成后再响应外部请求。3、输出信息 通过Delphi编译出可视化界面,形象地输出电梯基本信息,如运动状态,所在层数,开关门状态等。 算法的流程图开 始先请求先响应响应最短路程请求判断是内请求还是外请求响应结束判断电梯是否正在运动判断是否有请求电梯信息初始化并等待请求 N Y N Y 外请求判断是否有与运动方向相同请求 内请求 N先请求先响应 Y图一:算法流程图 算法的设计与分析private mshowin:boolean; /判断Groupboxin是否可见 mshowout:boolean; /判断Groupboxout是否可见 canmove:boolean; /用来延迟一会循环 whichclick:integer; /判断是开门还是关门 imagel:integer; /门图片的left imagew:integer; /门图片的Width elet:integer; /eleshape的top doorready:boolean; /电梯门是否准备好 elemove:boolean; /电梯是否运动 movedrect:integer; /电梯运动方向 elelocatefloor:integer; /电梯所在楼层 nowcall:integer; /现在几楼要求电梯运动 targetfloor:integer; /电梯运动的目标楼层 mincallup:integer; /电梯外部向下运动的最低楼层 maxcalldown:integer; /电梯外部向上运动的最高楼层 targetobject:integer; /电梯内部要求运动的楼层 nowtarget:integer; /现在电梯内部要求运动的楼层 downarray:array2.7 of boolean; /外部向下运动的按纽 uparray:array1.6 of boolean; /外部向上运动的按纽 targetarray:array1.7 of boolean; /内部运动的按纽 procedure waittwosecond(); /等待2秒,一等待过程,不一定是1秒 procedure waitonesecond(); /等待1秒,同上 procedure dooropenclose(); /开门关门动作 procedure eleincall(now:integer); /电梯里面要求运动 procedure eleoutcall(now:integer); /电梯外面要求运动 procedure lighton(nowstate:integer); /点亮所在楼层字体 procedure lightoff(nowstate:integer); /关掉所在楼层字体 procedure downoff(nowstate:integer); /关掉向下按纽 procedure upoff(nowstate:integer); /关掉向上按纽 procedure targetoff(nowstate:integer); /关掉内部按纽 procedure doorbitopen(); /实现开门动作 procedure doorbitclose(); /实现关门动作 procedure wait3sec(); /实现等待3秒 procedure waitformove(); /用来等待shape的运动 procedure showin(); /用来使groupboxin可见 procedure showout(); /用来使groupboxout可见 procedure lightofftarget(); /用来是关掉内部按纽颜色 Function moverequire():integer; /运动一回合后是否还要运动 Function getnowcallup():boolean; /是否还有向上的请求 Function getnowcalldown():boolean; /是否还有向下的请求 function getinman(sender:Tobject): integer;/计算进入电梯人数 function getoutman(sender:Tobject):integer;/计算走出电梯人数 运行结果与分析(测试)运行成功后界面如下:图二:初始化界面(2)图三: 电梯运动界面(1)图四: 电梯开门界面(3) 总结(收获与体会)在两周内就完成了数据结构课程设计。虽然课程设计已告一段落,但是还有好多东西需要去调试,学习。通过这次设计,我学到了许多书本上学不到的知识,增强了自己的动手能力,熟悉了Delphi语言。我十分珍惜这次锻炼的机会,我如期的完成了自己的设计任务,但由于知识水平有限,仍然存在很多的不足之处。今后在学习其他专业课时,我会珍惜每一次上机机会,锻炼自己的动手能力,加强专业知识,以适应毕业后从事计算机等方面的工作。 附:源代码unit unit1;interfaceuses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Buttons, ExtCtrls;type TForm1 = class(TForm) GroupBox1: TGroupBox; floor7: TLabel; floor2: TLabel; floor1: TLabel; floor5: TLabel; floor3: TLabel; floor4: TLabel; floor6: TLabel; GroupBox2: TGroupBox; eledoorstate: TLabel; eledown2: TBitBtn; eleup2: TBitBtn; eleup3: TBitBtn; eledown3: TBitBtn; eledown4: TBitBtn; eleup4: TBitBtn; eledown5: TBitBtn; eleup5: TBitBtn; eleup6: TBitBtn; eledown6: TBitBtn; eledown7: TBitBtn; target7: TBitBtn; target6: TBitBtn; target1: TBitBtn; target4: TBitBtn; target5: TBitBtn; target2: TBitBtn; target3: TBitBtn; doorclose: TBitBtn; eleup1: TBitBtn; doortimer: TTimer; eletimer: TTimer; dooropen: TBitBtn; about: TButton; exitdemo: TButton; GroupBox3: TGroupBox; elelocate1: TLabel; elestate2: TLabel; elemovedown1: TLabel; elemoveup1: TLabel; GroupBoxin: TGroupBox; manin1: TRadioButton; manin6: TRadioButton; GroupBoxout: TGroupBox; manout1: TRadioButton; manout6: TRadioButton; manin2: TRadioButton; manin7: TRadioButton; manin3: TRadioButton; manin8: TRadioButton; manin4: TRadioButton; manin9: TRadioButton; manin5: TRadioButton; manin10: TRadioButton; manout2: TRadioButton; manout3: TRadioButton; manout4: TRadioButton; manout5: TRadioButton; manout7: TRadioButton; manout8: TRadioButton; manout9: TRadioButton; manout10: TRadioButton; Panel1: TPanel; Panel2: TPanel; eleShape: TShape; doorimage: TImage; doorocTimer: TTimer; ElemoveTimer: TTimer; waitTimer: TTimer; GroupBox4: TGroupBox; elestate3: TLabel; elemoveup2: TLabel; elemovedown2: TLabel; elelocate2: TLabel; procedure doorcloseClick(Sender: TObject); procedure dooropenClick(Sender: TObject); procedure doortimerTimer(Sender: TObject); procedure target1Click(Sender: TObject); procedure target3Click(Sender: TObject); procedure target2Click(Sender: TObject); procedure target4Click(Sender: TObject); procedure target5Click(Sender: TObject); procedure target6Click(Sender: TObject); procedure target7Click(Sender: TObject); procedure eledown7Click(Sender: TObject); procedure eledown6Click(Sender: TObject); procedure eledown5Click(Sender: TObject); procedure eledown4Click(Sender: TObject); procedure eledown3Click(Sender: TObject); procedure eledown2Click(Sender: TObject); procedure eleup1Click(Sender: TObject); procedure eleup2Click(Sender: TObject); procedure eleup3Click(Sender: TObject); procedure eleup4Click(Sender: TObject); procedure eleup5Click(Sender: TObject); procedure eleup6Click(Sender: TObject); procedure eletimerTimer(Sender: TObject); procedure FormCreate(Sender: TObject); procedure aboutClick(Sender: TObject); procedure exitdemoClick(Sender: TObject); procedure doorocTimerTimer(Sender: TObject); procedure ElemoveTimerTimer(Sender: TObject); procedure waitTimerTimer(Sender: TObject); private Private declarations mshowin:boolean; /判断Groupboxin是否可见 mshowout:boolean; /判断Groupboxout是否可见 canmove:boolean; /用来延迟一会循环 whichclick:integer; /判断是开门还是关门 imagel:integer; /门图片的left imagew:integer; /门图片的Width elet:integer; /eleshape的top doorready:boolean; /电梯门是否准备好 elemove:boolean; /电梯是否运动 movedrect:integer; /电梯运动方向 elelocatefloor:integer; /电梯所在楼层 nowcall:integer; /现在几楼要求电梯运动 targetfloor:integer; /电梯运动的目标楼层 mincallup:integer; /电梯外部向下运动的最低楼层 maxcalldown:integer; /电梯内部要求运动的楼层 nowtarget:integer; /电梯外部向上运动的最高楼层 targetobject:integer; /现在电梯内部要求运动的楼层 downarray:array2.7 of boolean; /外部向下运动的按纽 uparray:array1.6 of boolean; /外部向上运动的按纽 targetarray:array1.7 of boolean; /内部运动的按纽 procedure waittwosecond(); /等待2秒,一个等待过程,不一定是一秒 procedure waitonesecond(); /等待1秒,同上 procedure dooropenclose(); /开门关门动作 procedure eleincall(now:integer); /电梯里面要求运动 procedure eleoutcall(now:integer); /电梯外面要求运动 procedure lighton(nowstate:integer); /点亮所在楼层字体 procedure lightoff(nowstate:integer); /关掉所在楼层字体 procedure downoff(nowstate:integer); /关掉向下按纽 procedure upoff(nowstate:integer); /关掉向上按纽 procedure targetoff(nowstate:integer); /关掉内部按纽 procedure doorbitopen(); /实现开门动作 procedure doorbitclose(); /实现关门动作 procedure wait3sec(); /实现等待3秒 procedure waitformove(); /用来等待shape的运动 procedure showin(); /用来使groupboxin可见 procedure showout(); /用来使groupboxout可见 procedure lightofftarget(); /用来是关掉内部按纽颜色 Function moverequire():integer; /运动一回合后是否还要运动 Function getnowcallup():boolean; /是否还有向上的请求 Function getnowcalldown():boolean; /是否还有向下的请求 function getinman(sender:Tobject): integer; /计算进入电梯的人数 function getoutman(sender:Tobject):integer; /计算走出电梯的人数 public Public declarations end;var Form1: TForm1;implementation$R *.DFMprocedure TForm1.lightofftarget(); /以下过程为初始化电梯内部按钮颜色var i:integer;begin case movedrect of 1:begin for i:=elelocatefloor downto 1 do /向下运动 begin targetoff(i); targetarrayi:=False;end;end; -1:begin for i:=elelocatefloor to 7 do /向上运动 begin targetoff(i); targetarrayi:=False; end;end; end;end;procedure TForm1.showin();beginif mshowin=true then groupboxin.Visible:=True; /电梯外部有人响应时if mshowout=True then groupboxout.Visible:=True; /电梯内部有人响应时end;procedure TForm1.showout();beginmshowin:=False;mshowout:=False;Groupboxin.Visible:=False;Groupboxout.Visible:=False;end;function TForm1.getinman(Sender:Tobject):integer;beginwith Groupboxin do case (Sender as TRadioButton).tag of /进入电梯人数的设置 1:getinman:=1; 2:getinman:=2; 3:getinman:=3; 4:getinman:=4; 5:getinman:=5; 6:getinman:=6; 7:getinman:=7; 8:getinman:=8; 9:getinman:=9; 10:getinman:=10; end;end;function TForm1.getoutman(Sender:Tobject):integer;beginwith Groupboxout do case (Sender as TRadioButton).tag of /走出电梯的人数 1:getoutman:=1; 2:getoutman:=2; 3:getoutman:=3; 4:getoutman:=4; 5:getoutman:=5; 6:getoutman:=6; 7:getoutman:=7; 8:getoutman:=8; 9:getoutman:=9; 10:getoutman:=10; end;end; procedure TForm1.waitformove();beginelemove:=true; /若电梯开始运动,则其动态效果在时钟控件作用下实现elemovetimer.Enabled:=True;end;procedure TForm1.wait3sec();beginwaittimer.Enabled:=True;end;procedure TForm1.doorbitopen();begindooroctimer.Enabled:=True;whichclick:=1; /开门状态end;procedure TForm1.doorbitclose();begindooroctimer.Enabled:=True;whichclick:=-1; /关门状态end;-初始状态-procedure TForm1.FormCreate(Sender: TObject);beginshape 336 48137 imagel:=68; /对图片进行初始化imagew:=1;Doorimage.Left:=imagel;Doorimage.Width:=imagew;Eleshape.Brush.Color:=clblue;elet:=288;eleshape.top:=elet;canmove:=True;elelocatefloor:=1;floor1.Font.color:=clred;elelocate1.font.color:=clred;elelocate2.font.color:=clred;elelocate1.caption:=inttostr(elelocatefloor);elelocate2.caption:=inttostr(elelocatefloor);doorready:=true;elemove:=false;movedrect:=0;mshowin:=False;mshowout:=False;Targetfloor:=1;end;-以下是定时器,实现2和1秒等待!-procedure TForm1.waittwosecond();begindoortimer.enabled:=True;end;procedure TForm1.waitonesecond();begineletimer.enabled:=true;end;-以下是开门和关门过程-procedure TForm1.dooropenclose();begineletimer.Enabled:=False;doorready:=false;dooropen.Font.color:=clred;doorclose.Font.color:=clwindowtext;eledoorstate.font.color:=clred;eledoorstate.caption:=正在开门!; /开门过程的实现showin();doorbitopen();waittwosecond();end;-定时器doortimer- procedure TForm1.doortimerTimer(Sender: TObject);beginif waittimer.Enabled=True then exit;if (elemove=true) and (dooroctimer.Enabled=True) then exit;eledoorstate.caption:= ;if doorready=true then doorclose.font.color:=clWindowtext;doortimer.enabled:=false;if doorready=false then begin eledoorstate.Font.color:=clred; dooropen.font.color:=clWindowtext; doorclose.font.color:=clred; eledoorstate.caption:=正在关门!; /关门过程的实现 showout(); doorbitclose(); waittwosecond(); doorready:=true; if elelocatefloor=Targetfloor then begin if moverequire()=-1 then begin /还有向上的请求 elemoveup1.font.color:=clwindowtext; elemoveup2.font.color:=clwindowtext; eleoutcall(nowcall);end else if moverequire()=1 then begin /还有向下的请求 elemovedown1.font.color:=clwindowtext; elemovedown2.font.color:=clwindowtext; eleoutcall(nowcall);end;end; end;if eledoorstate.caption= then doorready:=true;if elelocatefloortargetfloor then begin doortimer.Enabled:=False; eletimer.Enabled:=True; end;if moverequire()=0 then begin /到达了目标层并且没有请求 if dooroctimer.enabled=False then begin elemoveup1.font.color:=clwindowtext; elemoveup2.font.color:=clwindowtext; elemovedown1.font.color:=clwindowtext; elemovedown2.font.color:=clwindowtext; end; elemove:=False;end;end;-以下是click 实现开门-procedure TForm1.dooropenClick(Sender: TObject);begin if imagel=4 then exit; if elet mod 48 0 then exit; if dooroctimer.Enabled=true then dooroctimer.Enabled:=False; eledoorstate.font.color:=clred; dooropen.font.color:=clred; doorclose.font.color:=clWindowtext; eledoorstate.caption:=正在开门!; showin(); doorbitopen(); waittwosecond(); doorready:=false;end;-以下是click |=68 then exit; if elet mod 48 0 then exit; if dooroctimer.Enabled=true then dooroctimer.Enabled:=False; eledoorstate.font.color:=clred; dooropen.font.color:=clwindowtext; doorclose.font.color:=clred; eledoorstate.caption:=正在关门!; showout(); doorbitclose(); waittwosecond();end;-是否还有向上的请求- Function Tform1.getnowcallup():boolean;var i:integer;begingetnowcallup:=False;for i:=elelocatefloor to 7 do begin if targetarrayi=true then / 内部按钮的运动 begin nowcall:=i; targetobject:=i; if nowcalli then nowcall:=i; getnowcallup:=True; end; if ii then nowcall:=i; getnowcallup:=True; end; end; if i1 then begin if downarrayi=true then /外部按钮向下的运动 begin nowcall:=i; maxcalldown:=i; if nowcalli then nowcall:=i; get

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论