======================================================================================
这仅仅是一个很简单的医院挂号系统,虽然涉及到一些C/S架构思想,但并没有按照C/S架构去实现
还请大家见谅!!!
======================================================================================
**************************************************************************************
首先,新建一些辅助的类。
比如:Patients类,用于存放挂号的病人;Init类,用于预先存储一些病人,这样就可以方
便的测试Doctor类;还有一个Server类,相当于一个服务器。
**************************************************************************************
Patients类
package Queue;
/**
定义一个Patients类,这个类从写了toString方法,可以方便的进行输出!
*/
public class Patients {
private String name;
private String id;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
//这里从写了toString方法
public String toString(){
return "病人的ID是: " + this.id + " \n\n病人的姓名是: " + this.name;
}
}
Init类:
package Queue;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
import java.util.Queue;
/**
*
* @author toveping
* 向一个队列中加入一些病人,对医生的客户端进行测试!!!
*
*
*/
public class Init {
public Map init(String no){
Map<String, LinkedList<Patients>> queueSystem = new HashMap<String, LinkedList<Patients>>();
LinkedList<Patients> patQueue = new LinkedList<Patients>();
for(int i =0;i<20;i++){
Patients p = new Patients();
p.setId(i + "");
p.setName("A" + i);
patQueue.add(p);
}
queueSystem.put(no, patQueue);
return queueSystem;
}
}
Server类:
package Queue;
/**
定义一个Server类相当于服务器,挂号客户端增加一个病人的话,相应的存储在这里,可以供Doctor调用!!!
*/
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
import java.util.Queue;
public class Server {
//这是病人的队列
Queue<Patients> patQueue = new LinkedList<Patients>();
//String 是医生的代号 ;Queue 是病人的队列
Map<String, Queue> queueSystem = new HashMap<String, Queue>();
public int serverAdd(String no){
Map<String, LinkedList<Patients>> queueSystem = new HashMap<String, LinkedList<Patients>>();
LinkedList<Patients> patQueue = new LinkedList<Patients>();
Patients p = new Patients();
p.setId(patQueue.size()+"");
patQueue.add(p);
queueSystem.put(no, patQueue);
return patQueue.size();
}
}
**************************************************************************************
下面是挂号客户端:
**************************************************************************************
package Queue;
/**
这是一个挂号客户端,对会诊的病人进行挂号,以及方便挂号的病人容易的挂到自己想要的专家!!!
*/
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.FillLayout;
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 Client {
public static void main(String[] args){
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
shell.setText("专家挂号系统");
shell.open();
shell.setBounds(190, 100, 800, 600);
final Text txt = new Text(shell,SWT.MULTI);
txt.setBounds(200, 50, 400, 300);
Button firstButton = new Button(shell,SWT.NULL);
firstButton.setText("一号专家");
firstButton.setBounds(100, 400, 120, 65);
firstButton.addSelectionListener(new SelectionAdapter() {
Server ser = new Server();
int i = ser.serverAdd("1");
public void widgetSelected(SelectionEvent e) {
txt.setText("挂号成功\n" + "您选的专家是一号专家\n" + "您前面有" + i + "\n请耐心等待!!");
i++;
}
});
Button secondButton = new Button(shell,SWT.NULL);
secondButton.setText("二号专家");
secondButton.setBounds(250, 400, 120, 65);
secondButton.addSelectionListener(new SelectionAdapter() {
Server ser = new Server();
int i = ser.serverAdd("2");
public void widgetSelected(SelectionEvent e) {
txt.setText("挂号成功\n" + "您选的专家是二号专家\n" + "您前面有" + i + "\n请耐心等待!!");
i++;
}
});
Button thirdButton = new Button(shell,SWT.NULL);
thirdButton.setText("三号专家");
thirdButton.setBounds(400, 400, 120, 65);
thirdButton.addSelectionListener(new SelectionAdapter() {
Server ser = new Server();
int i = ser.serverAdd("3");
public void widgetSelected(SelectionEvent e) {
txt.setText("挂号成功\n" + "您选的专家是三号专家\n" + "您前面有" + i + "\n请耐心等待!!");
i++;
}
});
Button fourthButton = new Button(shell,SWT.NULL);
fourthButton.setText("四号专家");
fourthButton.setBounds(550, 400, 120, 65);
fourthButton.addSelectionListener(new SelectionAdapter() {
Server ser = new Server();
int i = ser.serverAdd("4");
public void widgetSelected(SelectionEvent e) {
txt.setText("挂号成功\n" + "您选的专家是四号专家\n" + "您前面有" + i + "\n请耐心等待!!");
i++;
}
});
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
}
运行结果如下图:
**************************************************************************************
最后是Doctor的客户端:
**************************************************************************************
package Queue;
/**
这里定义了Doctor使用的客户端,用来显示会诊的一些基本信息!
*/
import java.util.LinkedList;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.FillLayout;
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 Doctor {
public static void main(String[] args){
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
shell.setText("医生会诊系统");
shell.open();
shell.setMaximized(true);
final Text firsttxt = new Text(shell,SWT.MULTI);
firsttxt.setBounds(100, 50, 200, 300);
Button firstButton = new Button(shell,SWT.NULL);
firstButton.setText("下一个(一号专家)");
firstButton.setBounds(150, 400, 120, 65);
firstButton.addSelectionListener(new SelectionAdapter() {
Init aInit = new Init();
LinkedList lin = (LinkedList) aInit.init("1").get("1");
public void widgetSelected(SelectionEvent e) {
firsttxt.setText("\n您正在诊断的病人信息:\n\n" + lin.remove());
}
});
final Text secondtxt = new Text(shell,SWT.MULTI);
secondtxt.setBounds(400, 50, 200, 300);
Button secondButton = new Button(shell,SWT.NULL);
secondButton.setText("下一个(二号专家)");
secondButton.setBounds(450, 400, 120, 65);
secondButton.addSelectionListener(new SelectionAdapter() {
Init aInit = new Init();
LinkedList lin = (LinkedList) aInit.init("2").get("2");
public void widgetSelected(SelectionEvent e) {
secondtxt.setText("\n您正在诊断的病人信息:\n\n" + lin.remove());
}
});
final Text thirdtxt = new Text(shell,SWT.MULTI);
thirdtxt.setBounds(750, 50, 200, 300);
Button thirdButton = new Button(shell,SWT.NULL);
thirdButton.setText("下一个(三号专家)");
thirdButton.setBounds(800, 400, 120, 65);
thirdButton.addSelectionListener(new SelectionAdapter() {
Init aInit = new Init();
LinkedList lin = (LinkedList) aInit.init("3").get("3");
public void widgetSelected(SelectionEvent e) {
thirdtxt.setText("\n您正在诊断的病人信息:\n\n" + lin.remove());
}
});
final Text fourthtxt = new Text(shell,SWT.MULTI);
fourthtxt.setBounds(1050, 50, 200, 300);
Button fourthButton = new Button(shell,SWT.NULL);
fourthButton.setText("下一个(四号专家)");
fourthButton.setBounds(1100, 400, 120, 65);
fourthButton.addSelectionListener(new SelectionAdapter() {
Init aInit = new Init();
LinkedList lin = (LinkedList) aInit.init("4").get("4");
public void widgetSelected(SelectionEvent e) {
fourthtxt.setText("\n您正在诊断的病人信息:\n\n" + lin.remove());
}
});
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
}
运行的结果如下图:
**************************************************************************************
让大家见笑了!
posted on 2010-10-31 21:10
tovep 阅读(376)
评论(0) 编辑 收藏