银行排队系统源程序清单

银行排队系统源程序清单

ID:33112689

大小:146.50 KB

页数:16页

时间:2019-02-20

银行排队系统源程序清单_第1页
银行排队系统源程序清单_第2页
银行排队系统源程序清单_第3页
银行排队系统源程序清单_第4页
银行排队系统源程序清单_第5页
资源描述:

《银行排队系统源程序清单》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、第16页共16页三.源程序清单CSeqBankQueue.cs类代码usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Threading;namespace银行排队系统{classCSeqBankQueue:CSeqQueue,IBankQueue{privateintcallnumber;//记录系统自动产生的新来顾客的服务号//叫号属性publicintCallnumber{get{

2、returncallnumber;}set{callnumber=value;}}publicCSeqBankQueue(){}publicCSeqBankQueue(intsize):base(size){}//获得服务号码publicintGetCallnumber(){if((IsEmpty())&&callnumber==0)callnumber=1;elsecallnumber++;returncallnumber;}}//服务窗口类classServiceWindow{IBankQueuebankQ;public

3、IBankQueueBankQ第16页共16页{get{returnbankQ;}set{bankQ=value;}}publicvoidService(){while(true){Thread.Sleep(10000);if(!bankQ.IsEmpty()){Console.WriteLine();lock(bankQ){Console.WriteLine("请{0}号到{1}号窗口!",bankQ.DeQueue(),Thread.CurrentThread.Name);}}}}}}CSeqQueue.cs类代码usi

4、ngSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;namespace银行排队系统{publicclassCSeqQueue:IQueue{privateintmaxsize;//循环顺序队列的容量privateT[]data;//数组,用于存储循环顺序队列中的数据元素privateintfront;//指示最近一个己经离开队列的元素所占的位置第16页共16页privateintrear;//指示最近一个进行入队列的

5、元素的位置//索引器publicTthis[intindex]{get{returndata[index];}set{data[index]=value;}}//容量属性publicintMaxsize{get{returnmaxsize;}set{maxsize=value;}}//队头指示器属性publicintFront{get{returnfront;}set{front=value;}}//队尾指示器属性publicintRear{get{returnrear;}第16页共16页set{rear=value;}}/

6、/初始化队列publicCSeqQueue(){}publicCSeqQueue(intsize){data=newT[size];maxsize=size;front=rear=-1;}//入队操作publicvoidEnQueue(Telem){if(IsFull()){Console.WriteLine("Queueisfull");return;}rear=(rear+1)%maxsize;;data[rear]=elem;}//出队操作publicTDeQueue(){if(IsEmpty()){Console.W

7、riteLine("Queueisempty");returndefault(T);}front=(front+1)%maxsize;returndata[front];}//获取队头数据元素publicTGetFront(){if(IsEmpty()){Console.WriteLine("Queueisempty!");returndefault(T);第16页共16页}returndata[(front+1)%maxsize];}//求循环顺序队列的长度publicintGetLength(){return(rear-

8、front+maxsize)%maxsize;}//判断循环顺序队列是否为满publicboolIsFull(){if((front==-1&&rear==maxsize-1)

9、

10、(rear+1)%maxsize==front){returntrue;}else{returnfalse;}

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

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

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