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

上传人:b****4 文档编号:12355868 上传时间:2023-04-18 格式:DOCX 页数:23 大小:17.90KB
下载 相关 举报
银行排队系统源程序清单.docx_第1页
第1页 / 共23页
银行排队系统源程序清单.docx_第2页
第2页 / 共23页
银行排队系统源程序清单.docx_第3页
第3页 / 共23页
银行排队系统源程序清单.docx_第4页
第4页 / 共23页
银行排队系统源程序清单.docx_第5页
第5页 / 共23页
点击查看更多>>
下载资源
资源描述

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

《银行排队系统源程序清单.docx》由会员分享,可在线阅读,更多相关《银行排队系统源程序清单.docx(23页珍藏版)》请在冰豆网上搜索。

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

银行排队系统源程序清单

3.源程序清单

CSeqBankQueue.cs类代码

usingSystem;

usingSystem.Collections.Generic;

usingSystem.Linq;

usingSystem.Text;

usingSystem.Threading;

namespace银行排队系统

{

classCSeqBankQueue:

CSeqQueue,IBankQueue

{

privateintcallnumber;//记录系统自动产生的新来顾客的服务号

//叫号属性

publicintCallnumber

{

get

{

returncallnumber;

}

set

{

callnumber=value;

}

}

publicCSeqBankQueue(){}

publicCSeqBankQueue(intsize):

base(size){}

//获得服务号码

publicintGetCallnumber()

{

if((IsEmpty())&&callnumber==0)

callnumber=1;

else

callnumber++;

returncallnumber;

}

}

//服务窗口类

classServiceWindow

{

IBankQueuebankQ;

publicIBankQueueBankQ

{

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类代码

usingSystem;

usingSystem.Collections.Generic;

usingSystem.Linq;

usingSystem.Text;

namespace银行排队系统

{

publicclassCSeqQueue:

IQueue

{

privateintmaxsize;//循环顺序队列的容量

privateT[]data;//数组,用于存储循环顺序队列中的数据元素

privateintfront;//指示最近一个己经离开队列的元素所占的位置

privateintrear;//指示最近一个进行入队列的元素的位置

//索引器

publicTthis[intindex]

{

get

{

returndata[index];

}

set

{

data[index]=value;

}

}

//容量属性

publicintMaxsize

{

get

{

returnmaxsize;

}

set

{

maxsize=value;

}

}

//队头指示器属性

publicintFront

{

get

{

returnfront;

}

set

{

front=value;

}

}

//队尾指示器属性

publicintRear

{

get

{

returnrear;

}

set

{

rear=value;

}

}

//初始化队列

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.WriteLine("Queueisempty");

returndefault(T);

}

front=(front+1)%maxsize;

returndata[front];

}

//获取队头数据元素

publicTGetFront()

{

if(IsEmpty())

{

Console.WriteLine("Queueisempty!

");

returndefault(T);

}

returndata[(front+1)%maxsize];

}

//求循环顺序队列的长度

publicintGetLength()

{

return(rear-front+maxsize)%maxsize;

}

//判断循环顺序队列是否为满

publicboolIsFull()

{

if((front==-1&&rear==maxsize-1)||(rear+1)%maxsize==front)

{

returntrue;

}

else

{

returnfalse;

}

}

//清空循环顺序队列

publicvoidClear()

{

front=rear=-1;

}

//判断循环顺序队列是否为空

publicboolIsEmpty()

{

if(front==rear)

{

returntrue;

}

else

{

returnfalse;

}

}

}

}

IBankQueue.cs接口代码

usingSystem;

usingSystem.Collections.Generic;

usingSystem.Linq;

usingSystem.Text;

namespace银行排队系统

{

interfaceIBankQueue:

IQueue

{

intGetCallnumber();//获得服务号码

}

}

IQueue.cs接口代码

usingSystem;

usingSystem.Collections.Generic;

usingSystem.Linq;

usingSystem.Text;

namespace银行排队系统

{

interfaceIQueue

{

voidEnQueue(Telem);//入队列操作

TDeQueue();//出队列操作

TGetFront();//取对头元素

intGetLength();//求队列的长度

boolIsEmpty();//判断队列是否为空

voidClear();//清空队列

boolIsFull();//判断是否为满,在顺序队列中实现该算法,在链式队列中代码实现为空

}

}

Form1代码

usingSystem;

usingSystem.Collections.Generic;

usingSystem.ComponentModel;

usingSystem.Data;

usingSystem.Drawing;

usingSystem.Linq;

usingSystem.Text;

usingSystem.Windows.Forms;

namespace银行排队系统

{

publicpartialclassForm1:

Form

{

staticIBankQueuebankQueue=newCSeqBankQueue(100);

CSeqQueueq1=newCSeqQueue(100);

intCallnumber;

publicForm1()

{

InitializeComponent();

Form2f1=newForm2(this.q1);

Form3f2=newForm3(this.q1);

Form4f3=newForm4(this.q1);

f3.Show();

f2.Show();

f1.Show();

}

privatevoidbutton1_Click(objectsender,EventArgse)

{

if(!

bankQueue.IsFull())

{

Callnumber=bankQueue.GetCallnumber();

textBox1.Text="您的号码是"+Callnumber+"号";

bankQueue.EnQueue(Callnumber);

q1.EnQueue(Callnumber);

}

else

Console.WriteLine("现在业务繁忙,请稍后再来!

");

Console.WriteLine();

}

privatevoidbutton2_Click(objectsender,EventArgse)

{

Form5f5=newForm5();

f5.Show();

}

privatevoidForm1_Load(objectsender,EventArgse)

{

}

privatevoidtimer1_Tick(objectsender,EventArgse)

{

this.label4.Text="当前时间:

"+DateTime.Now.ToString();

}

privatevoidbutton3_Click(objectsender,EventArgse)

{

Form6f6=newForm6();

f6.Show();

}

}

}

Form2代码

usingSystem;

usingSystem.Collections.Generic;

usingSystem.ComponentModel;

usingSystem.Data;

usingSystem.Drawing;

usingSystem.Linq;

usingSystem.Text;

usingSystem.Windows.Forms;

namespace银行排队系统

{

publicpartialclassForm2:

Form

{

CSeqQueue_q1=newCSeqQueue(100);

publicForm2(CSeqQueueq1)

{

InitializeComponent();

this._q1=q1;

}

publicstaticinti=0;

publicstaticstringts;

DateTimeTime1=DateTime.Now;

privatevoidForm2_Load(objectsender,EventArgse)

{

}

privatevoidbutton1_Click(objectsender,EventArgse)

{

if(!

_q1.IsEmpty())

{

textBox1.Text="请"+_q1.DeQueue()+"号到一号窗口";

i++;

}

else

{

MessageBox.Show("现在没有客人!

","",MessageBoxButtons.OK,MessageBoxIcon.Warning);

}

}

privatevoidbutton2_Click(objectsender,EventArgse)

{

if(i!

=0)

{

DateTimeTime2=DateTime.Now;

TimeSpant=Time2-Time1;

ts=t.Seconds.ToString();

MessageBox.Show("服务完毕","OK",MessageBoxButtons.OK,MessageBoxIcon.Information);

}

elseMessageBox.Show("尚未服务","Error",MessageBoxButtons.OK,MessageBoxIcon.Error);

}

}

}

Form3代码

usingSystem;

usingSystem.Collections.Generic;

usingSystem.ComponentModel;

usingSystem.Data;

usingSystem.Drawing;

usingSystem.Linq;

usingSystem.Text;

usingSystem.Windows.Forms;

namespace银行排队系统

{

publicpartialclassForm3:

Form

{

CSeqQueue_q1=newCSeqQueue(100);

publicForm3(CSeqQueueq1)

{

InitializeComponent();

this._q1=q1;

}

publicstaticinti=0;

publicstaticstringts;

DateTimeTime1=DateTime.Now;

privatevoidForm3_Load(objectsender,EventArgse)

{

}

privatevoidbutton1_Click(objectsender,EventArgse)

{

if(!

_q1.IsEmpty())

{

textBox1.Text=("请"+_q1.DeQueue()+"号到二号窗口!

");

i++;

}

else

{

MessageBox.Show("现在没有客人!

","",MessageBoxButtons.OK,MessageBoxIcon.Warning);

}

}

privatevoidbutton2_Click(objectsender,EventArgse)

{

if(i!

=0)

{

DateTimeTime2=DateTime.Now;

TimeSpant=Time2-Time1;

ts=t.Seconds.ToString();

MessageBox.Show("服务完毕","OK",MessageBoxButtons.OK,MessageBoxIcon.Information);

}

elseMessageBox.Show("尚未服务","Error",MessageBoxButtons.OK,MessageBoxIcon.Error);

}

}

}

Form4代码

usingSystem;

usingSystem.Collections.Generic;

usingSystem.ComponentModel;

usingSystem.Data;

usingSystem.Drawing;

usingSystem.Linq;

usingSystem.Text;

usingSystem.Windows.Forms;

namespace银行排队系统

{

publicpartialclassForm4:

Form

{

CSeqQueue_q1=newCSeqQueue(100);

publicForm4(CSeqQueueq1)

{

InitializeComponent();

this._q1=q1;

}

publicstaticinti=0;

publicstaticstringts;

DateTimeTime1=DateTime.Now;

privatevoidForm4_Load(objectsender,EventArgse)

{

}

privatevoidbutton1_Click(objectsender,EventArgse)

{

if(!

_q1.IsEmpty())

{

textBox1.Text=("请"+_q1.DeQueue()+"号到三号窗口!

");

i++;

}

else

{

MessageBox.Show("现在没有客人!

","",MessageBoxButtons.OK,MessageBoxIcon.Warning);

}

}

 

privatevoidbutton2_Click(objectsender,EventArgse)

{

if(i!

=0)

{

DateTimeTime2=DateTime.Now;

TimeSpant=Time2-Time1;

ts=t.Seconds.ToString();

MessageBox.Show("服务完毕","OK",MessageBoxButtons.OK,MessageBoxIcon.Information);

}

elseMessageBox.Show("尚未服务","Error",MessageBoxButtons.OK,MessageBoxIcon.Error);

}

}

}

Form5代码

usingSystem;

usingSystem.Collections.Generic;

usingSystem.ComponentModel;

usingSystem.Data;

usingSystem.Drawing;

usingSystem.Linq;

usingSystem.Text;

usingSystem.Windows.Forms;

namespace银行排队系统

{

publicpartialclassForm5:

Form

{

publicForm5()

{

InitializeComponent();

}

doublesum,avg;

inti1=1;

privatevoidbutton1_Click(objectsender,EventArgse)

{

if(textBox1.Text!

=""&&System.Text.RegularExpressions.Regex.IsMatch(this.textBox1.Text.Trim(),"^[0-9]*$")&&double.Parse(textBox1.Text.ToString())>0&&double.Parse(textBox1.Text.ToString())<=5)

{

sum+=double.Parse(textBox1.Text.ToString());

avg=sum/i1;

i1++;

textBox1.Text="一号服务窗口平均得分"+avg;

}

else

{

MessageBox.Show("错误,请重新输入!

","一号窗口",MessageBoxButtons.OK,MessageBoxIcon.Error);

textBox1.Text="";

errorProvider1.SetError(textBox1,"不是1~5之间的整数");

}

}

privatevoidForm5_Load(objectsender,EventArgse)

{

 

}

privatevoidbutton2_Click(objectsender,EventArgse)

{

if(textBox2.Text!

=""&&System.Text.RegularExpressions.Regex.IsMatch(this.textBox2.Text.Trim(),"^[0-9]*$")&&double.Parse(textBox2.Text.ToString())>0&&double.Parse(textBox2.Text.ToString())<=5)

{

sum+=double.Parse(textBox2.Text.ToString());

avg=sum/i1;

i1++;

textBox2.Text="二号服务窗口平均得分"+avg;

}

else

{

MessageBox.Show("错误,请重新输入!

","二号窗口",MessageBoxButtons.OK,MessageBoxIcon.Error);

textBox2.Text="";

errorProvider1.SetError(textBox2,"不是1~5之间的整数");

}

}

privatevoidbutton3_Click(objectsender,EventArgse)

{

if(textBox3.Text!

=""&&System.Text.RegularExpressions.Regex.IsMatch(this.textBox3.Text.Trim(),"^[0-9]*$")&&double.Parse(textBox3.Text.ToString())>0&&double.Parse(textBox3.Text.ToSt

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

当前位置:首页 > 工程科技 > 电力水利

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1