java排队系统设计_医院排队系统之简易设计
有关排队系统的应用是很多的,本文是针对医院的排队挂号流程进行的简易设计。要设计排队系统,首先要分别设计出病人和专家的类,然后编写服务器类模拟出若干等侯的病人。最后分别编写出专家与病人的客户端。具体步骤及代码如下:
1.病人类。
package com.TinySK;
public class Pro {
private int proId;
private String proName;
private Patient patienter;
public Pro(Patient patienter){
this.patienter=patienter;
}
public int getProId() {
return proId;
}
public void setProId(int proId) {
this.proId = proId;
}
public String getProName() {
return proName;
}
public void setProName(String proName) {
this.proName = proName;
}
public Patient getPatienter() {
return patienter;
}
public void setPatienter(Patient patienter) {
this.patienter = patienter;
}
}
2.专家类。
package com.TinySK;
public class Pro {
private int proId;
private String proName;
private Patient patienter;
public Pro(Patient patienter){
this.patienter=patienter;
}
public int getProId() {
return proId;
}
public void setProId(int proId) {
this.proId = proId;
}
public String getProName() {
return proName;
}
public void setProName(String proName) {
this.proName = proName;
}
public Patient getPatienter() {
return patienter;
}
public void setPatienter(Patient patienter) {
this.patienter = patienter;
}
}
3.服务器端。
package com.TinySK;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
import java.util.Queue;
public class PatientServer {
private static int num=1;
public static int getNum() {
return num;
}
public static void setNum(int num) {
PatientServer.num = num;
}
Map> per=new HashMap>();
LinkedList waiterList1 = new LinkedList();
LinkedList waiterList2 = new LinkedList();
LinkedList waiterList3 = new LinkedList();
public Map> init(){
for(int i=1;i<=30;i++,num++){
Patient w1 = new Patient();
w1.setId(num);
w1.setFormer(i-1);
waiterList1.offer(w1);
}
per.put("冯医生",waiterList1);
for(int i=1;i<=20;i++,num++){
Patient w2 = new Patient();
w2.setId(num);
w2.setFormer(i-1);
waiterList2.offer(w2);
}
per.put("王医生",waiterList2);
for(int i=1;i<=10;i++,num++){
Patient w3 = new Patient();
w3.setId(num);
w3.setFormer(i-1);
waiterList3.offer(w3);
}
per.put("闫医生",waiterList3);
return per;
}
}
4.病人客户端。
package com.TinySK;
import java.util.Map;
import java.util.Queue;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
public class PatientUI {
public static void main(String[] args) {
final Display display = Display.getDefault();
final Shell shell = new Shell();
shell.setMaximized(true);
shell.setText("医院排队客户端");
// ------------------新插入的界面核心代码------------------------
PatientServer ps = new PatientServer();//实例化类
final Map> waiterList = ps.init();
//初始化队列服务器
final Text txt1 = new Text(shell,SWT.MULTI);
txt1.setBounds(150, 50, 200, 400);
// 事件代码里要访问button,所以加final
final Button button1 = new Button(shell, SWT.Activate);
button1.addSelectionListener(new SelectionAdapter() { // 加一个择监听器
public void widgetSelected(SelectionEvent e) {
Queue patient1List=waiterList.get("冯医生");
Patient patient1 = new Patient();
patient1.setId(patient1List.size()+1);
patient1.setFormer(patient1List.size());
patient1List.offer(patient1);
if(patient1List.size() <= 50){
txt1.setText( "您现在排在"+patient1.getId()+"位置上,\n您前面有"+patient1.getFormer()+"个人\n请您耐心等候吧!哈哈");
}else{
txt1.setText("您前面已经排50个人,请考虑!\n"+"您现在排在"+patient1.getId()+"位置上,\n您前面有"+patient1.getFormer()+"个人\n请您耐心等候吧!哈哈");
}
}
});
button1.setBounds(200, 530, 100, 40); // 设置按钮位置
button1.setFont(new Font(display,"宋体",12,SWT.BOLD));
button1.setText("冯医生");// 设置按钮上的文字
// ---------------------------------------------------------------
final Text txt2 = new Text(shell,SWT.MULTI);
txt2.setBounds(550, 50, 200, 400);
// 事件代码里要访问button,所以加final
final Button button2 = new Button(shell, SWT.Activate);
button2.addSelectionListener(new SelectionAdapter() { // 加一个择监听器
public void widgetSelected(SelectionEvent e) {
Queue patient2List=waiterList.get("王医生");
Patient patient2 = new Patient();
patient2.setId(patient2List.size()+1);
patient2.setFormer(patient2List.size());
patient2List.offer(patient2);
if(patient2List.size() <= 50){
txt2.setText( "您现在排在"+patient2.getId()+"位置上,\n您前面有"+patient2.getFormer()+"个人\n请您耐心等候吧!哈哈");
}else{
txt2.setText("您前面已经排50个人,请考虑!\n"+"您现在排在"+patient2.getId()+"位置上,\n您前面有"+patient2.getFormer()+"个人\n请您耐心等候吧!哈哈");
}
}
});
button2.setBounds(600, 530, 100, 40); // 设置按钮位置
button2.setFont(new Font(display,"宋体",12,SWT.BOLD));
button2.setText("王医生");// 设置按钮上的文字
//-----------------------------------------------------------------------------
final Text txt3 = new Text(shell,SWT.MULTI);
txt3.setBounds(950, 50, 200, 400);
// 事件代码里要访问button,所以加final
final Button button3 = new Button(shell, SWT.Activate);
button3.addSelectionListener(new SelectionAdapter() { // 加一个择监听器
public void widgetSelected(SelectionEvent e) {
Queue patient3List=waiterList.get("闫医生");
Patient patient3 = new Patient();
patient3.setId(patient3List.size()+1);
patient3.setFormer(patient3List.size());
patient3List.offer(patient3);
if(patient3List.size() <= 50){
txt3.setText( "您现在排在"+patient3.getId()+"位置上,\n您前面有"+patient3.getFormer()+"个人\n请您耐心等候吧!哈哈");
}else{
txt3.setText("您前面已经排50个人,请考虑!\n"+"您现在排在"+patient3.getId()+"位置上,\n您前面有"+patient3.getFormer()+"个人\n请您耐心等候吧!哈哈");
}
}
});
button3.setBounds(1000, 530, 100, 40); // 设置按钮位置
button3.setFont(new Font(display,"宋体",12,SWT.BOLD));
button3.setText("闫医生");// 设置按钮上的文字
shell.layout();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
}
}
病人客户端运行界面如图:
5.医生客户端。
package com.TinySK;
import java.util.Map;
import java.util.Queue;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
public class ProUI {public static void main(String[] args) {
final Display display = Display.getDefault();
final Shell shell = new Shell();
shell.setMaximized(true);
shell.setText("医院排队专家端");
// ------------------新插入的界面核心代码------------------------
PatientServer ps = new PatientServer();//实例化类
final Map> waiterList = ps.init();
//初始化队列服务器
final Text txt1 = new Text(shell,SWT.MULTI);
txt1.setBounds(150, 50, 200, 400);
// 事件代码里要访问button,所以加final
final Button button1 = new Button(shell, SWT.Activate);
button1.addSelectionListener(new SelectionAdapter() { // 加一个择监听器
public void widgetSelected(SelectionEvent e) {
Queue patient1List=waiterList.get("冯医生");
Patient patient1 = patient1List.poll();
txt1.setText("请 " + patient1.getId()+"号到冯医生那里就诊");
}
});
button1.setBounds(200, 530, 100, 40); // 设置按钮位置
button1.setFont(new Font(display,"宋体",12,SWT.BOLD));
button1.setText("冯医生");// 设置按钮上的文字
// ------------------Second--------------------------------------------
final Text txt2 = new Text(shell,SWT.MULTI);
txt2.setBounds(550, 50, 200, 400);
// 事件代码里要访问button,所以加final
final Button button2 = new Button(shell, SWT.Activate);
button2.addSelectionListener(new SelectionAdapter() { // 加一个择监听器
public void widgetSelected(SelectionEvent e) {
Queue patient2List=waiterList.get("王医生");
Patient patient2 = patient2List.poll();
txt2.setText("请 " + patient2.getId()+"号到冯医生那里就诊");
}
});
button2.setBounds(600, 530, 100, 40); // 设置按钮位置
button2.setFont(new Font(display,"宋体",12,SWT.BOLD));
button2.setText("王医生");// 设置按钮上的文字
//---------------------Third--------------------------------------------------------
final Text txt3 = new Text(shell,SWT.MULTI);
txt3.setBounds(950, 50, 200, 400);
// 事件代码里要访问button,所以加final
final Button button3 = new Button(shell, SWT.Activate);
button3.addSelectionListener(new SelectionAdapter() { // 加一个择监听器
public void widgetSelected(SelectionEvent e) {
Queue patient3List=waiterList.get("闫医生");
Patient patient3 = patient3List.poll();
txt3.setText("请 " + patient3.getId()+"号到冯医生那里就诊");
}
});
button3.setBounds(1000, 530, 100, 40); // 设置按钮位置
button3.setFont(new Font(display,"宋体",12,SWT.BOLD));
button3.setText("闫医生");// 设置按钮上的文字
shell.layout();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
}
}
医生客户端运行界面如图:
有关医院排队系统的简易模型就此完成,对于界面的美化,不再过多介绍。还有对于服务器端的模拟不太真实,这部分在实际应用中会很重要,而且要占一大部分内容,本文只是简单的模拟了一下服务器端。有关服务器端与用户端的结合使用,将在以后分析。本文写的不是很完善,若有问题请批评指正。
java排队系统设计_医院排队系统之简易设计相关推荐
- Java生鲜电商平台-促销系统的架构设计与源码解析
Java生鲜电商平台-促销系统的架构设计与源码解析 说明:本文重点讲解现在流行的促销方案以及源码解析,让大家对促销,纳新有一个深入的了解与学习过程. 促销系统是电商系统另外一个比较大,也是比较复杂的系 ...
- java 排队实现_实验排队功能实现(JAVA)
1.功能要求 实验室有固定台数的设备供学生通过网络连接进行实验,一台设备只能同时被一个用户使用,一个用户只能占用一台设备. 下面是一个功能的简图: 2.实现方案 2.1 初始化 在项目启动之后,开始进 ...
- 基于java的信访项目_基于web系统的信访设计与开发.doc
基于web系统的信访设计与开发 毕业设计 题 目 基于web系统的信访设计与开发 英文题目 Design and Development of visit Website 学生姓名: 学 号: 专 业 ...
- java商品销售_商品销售系统(Java).doc
淮海工学院计算机工程学院 实验报告书 课程名:<面向对象程序设计> 实验名称: Java深入面向对象编程 商品销售系统 班 级: 软件081 组 长: 组 员: 李宏志. 谢超 一.实验目 ...
- 基于JAVA的在线人才招聘求职系统【数据库设计、源码、开题报告】
主要使用技术 Servlet+JSP+CSS+JS+Mysql 数据库脚本 /* SQLyog Ultimate v9.30 MySQL - 5.5.40 : Database - jsp_qzzp_ ...
- matlab直流调速系统设计,直流调速系统的matlab设计与仿真系统设计
内容简介: 毕业设计 直流调速系统的matlab设计与仿真系统设计,共37页,16220字. 目录 1前言2 2双闭环直流调速系统的工作原理3 2.1双闭环直流调速系统的介绍3 2.2双闭环直流调速系 ...
- spring催办业务_业务后台系统之流程设计
上周在<业务后台系统之权限设计>中总结了自己在最近一个后台业务系统项目中的后台产品设计经验,本篇继续总结完后台设计三大内容中的流程设计. 首先,需要明确工作流联盟(WFMC)对工作流的定义 ...
- 毕业设计_校园志愿者系统平台的设计与实现
校园志愿者系统平台的设计与实现 1 系统介绍 校园志愿者系统是针对高校开发的,功能模块为志愿者模块.管理员模块.教师模块.志愿者模块包括登录.注册.找回密码.志愿活动信息.新闻动态.志愿者个人中心:管 ...
- java任务系统设计_任务调度系统-任务依赖的设计
1.任务依赖需求描述: 例子: 一个作业分为如下子任务: 任务1,任务2,任务3,任务4 执行的顺序为,任务1--->任务2,任务3--->任务4 其中任务2,任务3可以并行执行,我们用下 ...
最新文章
- matlab相关的数字信号,数字信号处理及其MATLAB实现.ppt
- 基于BP神经网络+HOG特征提取的视频中车辆车牌识别算法仿真
- centos 6.5 配置网络
- html中滚动栏的样式
- SQL Servr 2008空间数据应用系列一:空间信息基础
- 深层网络搜索核心技术研讨
- 信息技术手册查重错误比对分析程序开发记录3
- HyperMesh有限元分析报错集锦
- 大数据平台应用 17 个关键技术处理
- js中最简单base64图片流实现自动下载
- c语言系统编程项目实训,《C语言程序设计》项目实训指导书.doc
- 怎么查看笔记本内存条型号_查看笔记本内存条型号
- 大地高和正常高、正高的详细说明
- 怎么将英文文件翻译成中文
- Mac必备开源鼠标手势软件 MacStroke
- 顶点式超级计算机吗,有没有数学解题软件
- linux安装 cuda、cdunn、numpy、scipy、theano、pylearn2、scikit-neuralnetwork
- 网络上博弈——博弈匠心——真正的匠人精神
- 每日学习 与 每日未知
- Github配置ssh key【不用密码访问Github上代码】