数据结构大型实验

数据结构大型实验

ID:35311313

大小:83.00 KB

页数:11页

时间:2019-03-23

数据结构大型实验_第1页
数据结构大型实验_第2页
数据结构大型实验_第3页
数据结构大型实验_第4页
数据结构大型实验_第5页
资源描述:

《数据结构大型实验》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库

1、数据结构大型实验一、大型实验的性质、目的和任务综合运用数据结构,解决实际问题,体验程序开发过程二、整个系统的框架设计SimulationStoreSimulationArriveEventOrderEventLeaveEventEventSkewHeapCustomerGroup2.采用的模型和类的设计:A:事件类是抽象类,提供公共的事件处理Event:ArriveEvent顾客到达OrderEvent顾客点单LeaveEvent顾客离开B:模拟类Simulation是抽象类,提供用于事件管理的公共接口。C:冰淇淋店模拟类storeSimula

2、tion,继承并实现抽象类Simulation用于实际冰淇淋店事件管理。D:SkewHeap用于作为发生事件的存储容器E:Random用于随机数的产生F:CustomerGroup用于描述到店的顾客群三:事件描述ArriveEvent:是否有座ArriveEvent是触发定购事件离开事件触发否OrderEvent定购事件计算定购的总份额,并计算利润,加入总利润中LeaveEvent分析离开原因:1.因为无座离开2.用餐完毕离开记录空座位数离开事件查看原因21将顾客群从finish优先队列中删除输入信息四.附原代码(主要类)(1)主函数main#

3、include"event.h"#include"random.h"#include"arriveEvent.h"#include"customergroup.h"#include"storeSimulation.h"#include#includeconstintseatnum=10;constinthour=8;storeSimulationstore(seatnum);voidiceCreamStoreSimulation();voidmain(){cout<<""<<"冰淇淋店"<

4、eatnum<<"个座位,营业"<

5、ae);}store.run();store.printProfits();}(2)模拟类(simulation—抽象类)#ifndef_simulation#define_simulation#include"event.h"#include"skewHeap.h"#include#includeclasssimulation{public:simulation();voidrun();unsignedintcurrentTime();voidscheduleEvent(event*);intdone;protect

6、ed:skewHeapeventQueue;unsignedinttime;};simulation::simulation():time(0){}unsignedintsimulation::currentTime(){returntime;}voidsimulation::scheduleEvent(event*newEvent){assert(newEvent!=0);eventQueue.add(*newEvent);}voidsimulation::run(){done=eventQueue.isEmpty();while(!don

7、e){event&nextEvent=eventQueue.deleteMin();time=nextEvent.time;nextEvent.processEvent();delete&nextEvent;if(eventQueue.isEmpty())done=1;}}#endif(3)商店模拟类(storeSimulation)#ifndef_storeSimulation#define_storeSimulation#include"simulation.h"#include"arriveEvent.h"#include"orderEvent.h"#

8、include"leaveEvent.h"#incl

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。