收藏 分享(赏)

银行排队系统源程序清单.doc

上传人:HR专家 文档编号:11444893 上传时间:2020-04-29 格式:DOC 页数:16 大小:146.50KB
下载 相关 举报
银行排队系统源程序清单.doc_第1页
第1页 / 共16页
银行排队系统源程序清单.doc_第2页
第2页 / 共16页
银行排队系统源程序清单.doc_第3页
第3页 / 共16页
银行排队系统源程序清单.doc_第4页
第4页 / 共16页
银行排队系统源程序清单.doc_第5页
第5页 / 共16页
点击查看更多>>
资源描述

1、第 16 页 共 16 页3 源程序清单CSeqBankQueue.cs类代码using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading;namespace 银行排队系统 class CSeqBankQueue : CSeqQueue, IBankQueue private int callnumber;/记录系统自动产生的新来顾客的服务号 /叫号属性 public int Callnumber get return callnumber; se

2、t callnumber = value; public CSeqBankQueue() public CSeqBankQueue(int size) : base(size) /获得服务号码 public int GetCallnumber() if (IsEmpty() & callnumber = 0) callnumber = 1; else callnumber+; return callnumber; /服务窗口类 class ServiceWindow IBankQueue bankQ; public IBankQueue BankQ get return bankQ; set

3、bankQ = value; public void Service() while (true) Thread.Sleep(10000); if (!bankQ.IsEmpty() Console.WriteLine(); lock (bankQ) Console.WriteLine(请0号到1号窗口!, bankQ.DeQueue(), Thread.CurrentThread.Name); CSeqQueue.cs类代码using System;using System.Collections.Generic;using System.Linq;using System.Text;nam

4、espace 银行排队系统 public class CSeqQueue : IQueue private int maxsize; /循环顺序队列的容量 private T data; /数组,用于存储循环顺序队列中的数据元素 private int front; /指示最近一个己经离开队列的元素所占的位置 private int rear; /指示最近一个进行入队列的元素的位置 /索引器 public T thisint index get return dataindex; set dataindex = value; /容量属性 public int Maxsize get retur

5、n maxsize; set maxsize = value; /队头指示器属性 public int Front get return front; set front = value; /队尾指示器属性 public int Rear get return rear; set rear = value; /初始化队列 public CSeqQueue() public CSeqQueue(int size) data = new Tsize; maxsize = size; front = rear = -1; /入队操作 public void EnQueue(T elem) if (I

6、sFull() Console.WriteLine(Queue is full); return; rear = (rear + 1) % maxsize; ; datarear = elem; /出队操作 public T DeQueue() if (IsEmpty() Console.WriteLine(Queue is empty); return default(T); front = (front + 1) % maxsize; return datafront; /获取队头数据元素 public T GetFront() if (IsEmpty() Console.WriteLin

7、e(Queue is empty!); return default(T); return data(front + 1) % maxsize; /求循环顺序队列的长度 public int GetLength() return (rear - front + maxsize) % maxsize; /判断循环顺序队列是否为满 public bool IsFull() if (front = -1 & rear = maxsize - 1) | (rear + 1) % maxsize = front) return true; else return false; /清空循环顺序队列 pub

8、lic void Clear() front = rear = -1; /判断循环顺序队列是否为空 public bool IsEmpty() if (front = rear) return true; else return false; IBankQueue.cs接口代码using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace 银行排队系统 interface IBankQueue : IQueue int GetCallnumber();/获得服务号码 IQue

9、ue.cs接口代码using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace 银行排队系统 interface IQueue void EnQueue(T elem); /入队列操作 T DeQueue(); /出队列操作 T GetFront(); /取对头元素 int GetLength(); /求队列的长度 bool IsEmpty(); /判断队列是否为空 void Clear(); /清空队列 bool IsFull();/判断是否为满,在顺序队列中实现该算法,

10、在链式队列中代码实现为空 Form1代码using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace 银行排队系统 public partial class Form1 : Form static IBankQueue bankQueue = new CSeqBankQueue(100);

11、 CSeqQueue q1 = new CSeqQueue(100); int Callnumber; public Form1() InitializeComponent(); Form2 f1 = new Form2(this.q1); Form3 f2 = new Form3(this.q1); Form4 f3 = new Form4(this.q1); f3.Show(); f2.Show(); f1.Show(); private void button1_Click(object sender, EventArgs e) if (!bankQueue.IsFull() Calln

12、umber = bankQueue.GetCallnumber(); textBox1.Text = 您的号码是 + Callnumber + 号; bankQueue.EnQueue(Callnumber); q1.EnQueue(Callnumber); else Console.WriteLine(现在业务繁忙,请稍后再来!); Console.WriteLine(); private void button2_Click(object sender, EventArgs e) Form5 f5 = new Form5(); f5.Show(); private void Form1_L

13、oad(object sender, EventArgs e) private void timer1_Tick(object sender, EventArgs e) this.label4.Text = 当前时间: + DateTime.Now.ToString(); private void button3_Click(object sender, EventArgs e) Form6 f6 = new Form6(); f6.Show(); Form2代码using System;using System.Collections.Generic;using System.Compone

14、ntModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace 银行排队系统 public partial class Form2 : Form CSeqQueue _q1 = new CSeqQueue(100); public Form2(CSeqQueue q1) InitializeComponent(); this._q1 = q1; public static int i = 0; public static

15、 string ts; DateTime Time1 = DateTime.Now; private void Form2_Load(object sender, EventArgs e) private void button1_Click(object sender, EventArgs e) if (!_q1.IsEmpty() textBox1.Text = 请 + _q1.DeQueue() + 号到一号窗口; i+; else MessageBox.Show(现在没有客人!, , MessageBoxButtons.OK, MessageBoxIcon.Warning); priv

16、ate void button2_Click(object sender, EventArgs e) if (i != 0) DateTime Time2 = DateTime.Now; TimeSpan t = Time2 - Time1; ts = t.Seconds.ToString(); MessageBox.Show(服务完毕, OK, MessageBoxButtons.OK, MessageBoxIcon.Information); else MessageBox.Show(尚未服务, Error, MessageBoxButtons.OK, MessageBoxIcon.Err

17、or); Form3代码using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace 银行排队系统 public partial class Form3 : Form CSeqQueue _q1 = new CSeqQueue(100); public Form3(CSeqQueue q1

18、) InitializeComponent(); this._q1 = q1; public static int i = 0; public static string ts; DateTime Time1 = DateTime.Now; private void Form3_Load(object sender, EventArgs e) private void button1_Click(object sender, EventArgs e) if (!_q1.IsEmpty() textBox1.Text = (请 + _q1.DeQueue() + 号到二号窗口!); i+; el

19、se MessageBox.Show(现在没有客人!, , MessageBoxButtons.OK, MessageBoxIcon.Warning); private void button2_Click(object sender, EventArgs e) if (i != 0) DateTime Time2 = DateTime.Now; TimeSpan t = Time2 - Time1; ts = t.Seconds.ToString(); MessageBox.Show(服务完毕, OK, MessageBoxButtons.OK, MessageBoxIcon.Informa

20、tion); else MessageBox.Show(尚未服务, Error, MessageBoxButtons.OK, MessageBoxIcon.Error); Form4代码using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace 银行排队系统 public partial

21、 class Form4 : Form CSeqQueue _q1 = new CSeqQueue(100); public Form4(CSeqQueue q1) InitializeComponent(); this._q1 = q1; public static int i = 0; public static string ts; DateTime Time1 = DateTime.Now; private void Form4_Load(object sender, EventArgs e) private void button1_Click(object sender, Even

22、tArgs e) if (!_q1.IsEmpty() textBox1.Text = (请 + _q1.DeQueue() + 号到三号窗口!); i+; else MessageBox.Show(现在没有客人!, , MessageBoxButtons.OK, MessageBoxIcon.Warning); private void button2_Click(object sender, EventArgs e) if (i != 0) DateTime Time2 = DateTime.Now; TimeSpan t = Time2 - Time1; ts = t.Seconds.T

23、oString(); MessageBox.Show(服务完毕, OK, MessageBoxButtons.OK, MessageBoxIcon.Information); else MessageBox.Show(尚未服务, Error, MessageBoxButtons.OK, MessageBoxIcon.Error); Form5代码using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.

24、Linq;using System.Text;using System.Windows.Forms;namespace 银行排队系统 public partial class Form5 : Form public Form5() InitializeComponent(); double sum, avg; int i1 = 1; private void button1_Click(object sender, EventArgs e) if (textBox1.Text != & System.Text.RegularExpressions.Regex.IsMatch(this.text

25、Box1.Text.Trim(), 0-9*$) & double.Parse(textBox1.Text.ToString() 0 & double.Parse(textBox1.Text.ToString() 0 & double.Parse(textBox2.Text.ToString() 0 & double.Parse(textBox3.Text.ToString() = 5) sum += double.Parse(textBox3.Text.ToString(); avg = sum / i1; i1+; textBox3.Text = 三号服务窗口平均得分 + avg; els

26、e MessageBox.Show(错误,请重新输入!, 三号窗口, MessageBoxButtons.OK, MessageBoxIcon.Error); textBox3.Text = ; errorProvider1.SetError(textBox3, 不是15之间的整数); Form6代码using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace 银行排队系统 public partial class Form6 : Form public Form6() InitializeComponent(); private void button1_Click(object sender, EventArgs e) if (Form2.ts != null & Form2.i != 0)

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 金融证券 > 金融资料

本站链接:文库   一言   我酷   合作


客服QQ:2549714901微博号:道客多多官方知乎号:道客多多

经营许可证编号: 粤ICP备2021046453号世界地图

道客多多©版权所有2020-2025营业执照举报