posts - 14,  comments - 7,  trackbacks - 0
项目需求:1.病人来挂号时根据自己想找的医生挂相应的医生的号,即加到相应医生的病人队列中。
                   2.医生看见自己的屏幕,点击自己的名字,得到自己相应列表的下一位病人
具体代码如下:
医生:
package com.dr.queue;

import java.util.LinkedList;
import java.util.List;
import java.util.Queue;

public class Doctor {
    
private String dName;
    
private int dNum;
    
private Queue<Patient> patientList;
    
private Patient p;

    
public Patient getP() {
        
return p;
    }


    
public void setP(Patient p) {
        
this.p = p;
    }


    
public Doctor(String name, int dNum) {
        
this.setdName(dName);
        
this.setdNum(dNum);
        patientList 
= new LinkedList<Patient>();
        
// this.setPatientList(new LinkedList<Patient>());
    }


    
public Queue<Patient> getPatientList() {
        
return patientList;
    }


    
// public void setPatientList(Queue<Patient> patientList) {
    
// this.patientList = patientList;
    
// }
    public String getdName() {
        
return dName;
    }


    
public void setdName(String dName) {
        
this.dName = dName;
    }


    
public int getdNum() {
        
return dNum;
    }


    
public void setdNum(int dNum) {
        
this.dNum = dNum;
    }


    
public void offerPatient(Patient patient) {
        
this.patientList.offer(patient);
        
// return patientList;
    }


    
public void looking() {
        System.out.println(
"I handling the " + this.p.getpNum() + " waiter");
        
try {
            Thread.sleep(
100);
        }
 catch (InterruptedException e) {
            e.printStackTrace();
        }

        System.out.println(
"I have handled the patient,next ,next ,next");

    }


}

病人:
package com.dr.queue;

public class Patient {
    
private String pName;
package com.dr.ui;

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;

import com.dr.queue.Patient;
import com.dr.queue.QueueServer;

public class DoctorQueueUI {
    
public static void main(String[] args) {
        
final Display display = Display.getDefault();
        
final Shell shell = new Shell();
        shell.setMaximized(
true);
        shell.setText(
"医生使用客户端");

        
// final Map<Doctor,List<Patient>> m = new
        
// HashMap<Doctor,List<Patient>>();

        
final Text txt = new Text(shell, SWT.MULTI);
        txt.setBounds(
35050500450);

        QueueServer qs 
= new QueueServer();
        
final Queue<Patient> rosePL = qs.init("rose");
        
final Queue<Patient> xiaoPL = qs.init("xiaoxiao");
        
final Queue<Patient> yangPL = qs.init("yangguang");

        
final Button button1 = new Button(shell, SWT.Activate);
        button1.setBounds(
25053020075); // 设置按钮位置
        button1.setFont(new Font(display, "宋体"12, SWT.BOLD));
        button1.setText(
"一号专家rose");// 设置按钮上的文字

        button1.addSelectionListener(
new SelectionAdapter() {
            
public void widgetSelected(SelectionEvent e) {

                Patient patient 
= rosePL.poll();

                
if (patient != null{
                    txt.setText(
"" + patient.getpNum() + "号病人到一号专家rose这就诊!");
                }
 else {
                    txt.setText(
"现在没有病人就诊,您可以休息一下!");
                }

                
//                    
            }

        }
);
        
final Button button2 = new Button(shell, SWT.Activate);
        button2.setBounds(
50053020075); // 设置按钮位置
        button2.setFont(new Font(display, "宋体"12, SWT.BOLD));
        button2.setText(
"二号专家xiaoxiao");// 设置按钮上的文字

        button2.addSelectionListener(
new SelectionAdapter() {
            
public void widgetSelected(SelectionEvent e) {
                Patient patient 
= xiaoPL.poll();
                
if (patient != null{
                    txt
                            .setText(
"" + patient.getpNum()
                                    
+ "号病人到二号专家xiaoxiao这就诊");
                }
 else {
                    txt.setText(
"现在没有病人就诊,您可以休息一下");
                }

                
//                        
            }

        }
);
        
final Button button3 = new Button(shell, SWT.Activate);
        button3.setBounds(
75053020075); // 设置按钮位置
        button3.setFont(new Font(display, "宋体"12, SWT.BOLD));
        button3.setText(
"三好专家yangguang");// 设置按钮上的文字

        button3.addSelectionListener(
new SelectionAdapter() {
            
public void widgetSelected(SelectionEvent e) {

                Patient patient 
= yangPL.poll();

                
if (patient != null{
                    txt.setText(
"" + patient.getpNum()
                            
+ "号病人到三好专家yangguang这就诊");
                }
 else {
                    txt.setText(
"现在没有病人就诊,您可以休息一下");
                }

                
//                            
            }

        }
);

        shell.layout();
        shell.open();
        
while (!shell.isDisposed()) {
            
if (!display.readAndDispatch())
                display.sleep();
        }


    }

}


    
private int pNum;
    
private int frontNum;
    
public int getFrontNum() {
        
return frontNum;
    }

    
public void setFrontNum(int frontNum) {
        
this.frontNum = frontNum;
    }

    
public String getpName() {
        
return pName;
    }

    
public void setpName(String pName) {
        
this.pName = pName;
    }

    
public int getpNum() {
        
return pNum;
    }

    
public void setpNum(int pNum) {
        
this.pNum = pNum;
    }

    
}

病人挂号界面UI:
package com.dr.ui;

import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
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;

import com.dr.queue.Doctor;
import com.dr.queue.Patient;
import com.dr.queue.QueueServer;

public class PatientQueueUI {
    
public static void main(String[] args) {
        
final Display display = Display.getDefault();
        
final Shell shell = new Shell();
        shell.setMaximized(
true);
        shell.setText(
"医院排队病人使用客户端");

        
// final Map<Doctor,Queue<Patient>> m = new
        
// HashMap<Doctor,Queue<Patient>>();
        QueueServer qs = new QueueServer();
        
final Queue<Patient> rosePL = qs.init("rose");
        
final Queue<Patient> xiaoPL = qs.init("xiaoxiao");
        
final Queue<Patient> yangPL = qs.init("yangguang");

        
final Text txt = new Text(shell, SWT.MULTI);
        txt.setBounds(
35050500450);

        
final Button button1 = new Button(shell, SWT.Activate);
        button1.setBounds(
25053020075); // 设置按钮位置
        button1.setFont(new Font(display, "宋体"12, SWT.BOLD));
        button1.setText(
"一号专家rose");// 设置按钮上的文字
        final Button button2 = new Button(shell, SWT.Activate);
        button2.setBounds(
50053020075); // 设置按钮位置
        button2.setFont(new Font(display, "宋体"12, SWT.BOLD));
        button2.setText(
"二号专家xiaoxiao");// 设置按钮上的文字
        final Button button3 = new Button(shell, SWT.Activate);
        button3.setBounds(
75053020075); // 设置按钮位置
        button3.setFont(new Font(display, "宋体"12, SWT.BOLD));
        button3.setText(
"三号专家yangguang");// 设置按钮上的文字

        button1.addSelectionListener(
new SelectionAdapter() {
            
public void widgetSelected(SelectionEvent e) {
                Doctor d1 
= new Doctor("rose"1);
                Patient patient 
= new Patient();
                
// Queue<Patient> p1=m.get("xiaoxiao");
                
// d1.addPatient(patient);
                rosePL.offer(patient);

                patient.setpNum(rosePL.size());
                patient.setFrontNum(rosePL.size() 
- 1);
                
// m.put(d1, p1);

                
if (rosePL.size() <= 30{
                    txt.setText(
"一号专家为您就诊,\n" + "您现在排在" + rosePL.size()
                            
+ "号,\n" + "前面人数为" + patient.getFrontNum());
                }
 else {
                    txt
                            .setText(
"一号专家为您就诊" + "您现在排在" + rosePL.size() + ""
                                    
+ "您前面已有" + patient.getFrontNum()
                                    
+ "人,\n您可以考虑其他专家");
                }

                
//                        
            }

        }
);
        button2.addSelectionListener(
new SelectionAdapter() {
            
public void widgetSelected(SelectionEvent e) {
                Doctor d2 
= new Doctor("xiaoxiao"1);
                Patient patient 
= new Patient();
                
// d1.addPatient(patient);
                xiaoPL.offer(patient);

                patient.setpNum(xiaoPL.size());
                patient.setFrontNum(xiaoPL.size() 
- 1);
                
// m.put(d2, p2);

                
if (xiaoPL.size() <= 30{
                    txt.setText(
"二号专家为您就诊,\n" + "您现在排在" + rosePL.size()
                            
+ "号,\n" + "前面人数为" + patient.getFrontNum());
                }
 else {
                    txt
                            .setText(
"二号专家为您就诊,\n" + "您现在排在" + rosePL.size()
                                    
+ "" + "您前面已有" + patient.getFrontNum()
                                    
+ "人,\n您可以考虑其他专家");
                }

                
//                        
            }

        }
);
        button3.addSelectionListener(
new SelectionAdapter() {
            
public void widgetSelected(SelectionEvent e) {
                Doctor d3 
= new Doctor("yangguang"1);
                Patient patient 
= new Patient();
                
// d1.addPatient(patient);
                yangPL.offer(patient);

                patient.setpNum(yangPL.size());
                patient.setFrontNum(yangPL.size() 
- 1);
                
// m.put(d3, yangPL);
                
// System.out.println(m.get(d3));

                
if (yangPL.size() <= 30{
                    txt.setText(
"三号专家为您就诊,\n" + "您现在排在" + yangPL.size()
                            
+ "号,\n" + "前面人数为" + patient.getFrontNum());
                }
 else {
                    txt.setText(
"您前面已有" + patient.getFrontNum()
                            
+ "人,\n您可以考虑其他专家");
                }

                
//                        
            }

        }
);

        shell.layout();
        shell.open();
        
while (!shell.isDisposed()) {
            
if (!display.readAndDispatch())
                display.sleep();
        }

    }

}

医生界面UI:
挂号时运行界面如下,点击相应的专家会加到相应的专家中会是相应的专家为您就诊:
医生叫号时运行界面如下,相应的专家点击自己相应的名字可以出现自己相应的下一个病人的名字:
posted on 2010-11-02 16:51 迷人笑笑 阅读(3389) 评论(1)  编辑  收藏

FeedBack:
# re: java-医院病人排队挂号医生叫号简洁小系统
2012-04-16 17:33 | sss
代码不全 QueueServer 没有  回复  更多评论
  

只有注册用户登录后才能发表评论。


网站导航:
 
<2012年4月>
25262728293031
1234567
891011121314
15161718192021
22232425262728
293012345

常用链接

留言簿(13)

随笔档案

文章档案

搜索

  •  

最新评论

阅读排行榜

评论排行榜