<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    把困難踩在腳下

    迎難而上

     

    用GUI模擬醫(yī)院掛號系統(tǒng)

    要求:

    有三個專家,病人可以根據(jù)自己的實(shí)際情況選擇相應(yīng)的專家,專家通過點(diǎn)擊按鈕選擇下一個病人。

    程序代碼如下:

    //封裝病人類

    package com.dr.hospitalQueueSystem;

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

    public class Patient {
        private int num;
        private String name;
        public String getName() {
            return name;
        }
        public void setName(String name) {
            this.name = name;
        }
        public int getNum() {
            return num;
        }
        public void setNum(int num) {
            this.num = num;
        }
        public Patient(int num,String name)
        {
            this.setName(name);
            this.setNum(num);
        }

    }

    //封裝專家類

    package com.dr.hospitalQueueSystem;

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

    public class Professor {
        private String name;
        private int id;
        public int getId() {
            return id;
        }
        public void setId(int id) {
            this.id = id;
        }
        public String getName() {
            return name;
        }
        public void setName(String name) {
            this.setName(name);
        }
        public Professor(String name,int id)
        {
            this.name=name;
            this.id=id;
        }

    }

    //掛號服務(wù)器

    package com.dr.hospitalQueueSystem;

    import java.util.HashMap;
    import java.util.LinkedList;
    import java.util.Map;
    import java.util.Queue;

    public class HospitalQueueServer {
        Map<Integer,Queue<Patient>> map=new HashMap<Integer,Queue<Patient>>();
        Queue<Patient> patientList1=new LinkedList<Patient>();
        Queue<Patient> patientList2=new LinkedList<Patient>();
        Queue<Patient> patientList3=new LinkedList<Patient>();
        public void Init()
        {
            //實(shí)例化三個專家
            Professor pfr1=new Professor("張三",1);
            Professor pfr2=new Professor("李四",2);
            Professor pfr3=new Professor("王五",3);
            //實(shí)例化15個病人,并將他們每五個添加到三個專家所對應(yīng)的集合隊(duì)列中
            patientList1.offer(new Patient(1, "成龍"));
            patientList1.offer(new Patient(2, "李小龍"));
            patientList1.offer(new Patient(3, "大S"));
            patientList1.offer(new Patient(4, "郭富城"));
            patientList1.offer(new Patient(5, "小S"));
            patientList2.offer(new Patient(6, "劉德華"));
            patientList2.offer(new Patient(7, "林心如"));
            patientList2.offer(new Patient(8, "張靜初"));
            patientList2.offer(new Patient(9, "王寶強(qiáng)"));
            patientList2.offer(new Patient(10, "李連杰"));
            patientList3.offer(new Patient(11, "大傻"));
            patientList3.offer(new Patient(12, "張國榮"));
            patientList3.offer(new Patient(13, "周星馳"));
            patientList3.offer(new Patient(14, "趙薇"));
            patientList3.offer(new Patient(15, "周迅"));
            //將各個專家與他們對應(yīng)的病人集合進(jìn)行鍵值對
            map.put(pfr1.getId(), patientList1);
            map.put(pfr2.getId(), patientList2);
            map.put(pfr3.getId(), patientList3);
        }

    }

    //病人使用端

    package com.dr.hospitalQueueSystem;

    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.Label;
    import org.eclipse.swt.widgets.Shell;
    import org.eclipse.swt.widgets.Text;

    public class PatientQueueUI {
        public static void main(String args[])
        {
            Display display=new Display();
            Shell shell=new Shell(display);
            shell.setMaximized(true);
            //初始化界面
            shell.setText("醫(yī)院病人掛號使用系統(tǒng)");
            //服務(wù)器初始化
            HospitalQueueServer hq=new HospitalQueueServer();
            hq.Init();
            final Queue<Patient> patientList1=hq.map.get(1);
            final Queue<Patient> patientList2=hq.map.get(2);
            final Queue<Patient> patientList3=hq.map.get(3);
            //添加標(biāo)簽控件
            Label label=new Label(shell,SWT.NONE);
            label.setFont(new Font(display,"宋體",15,SWT.BOLD));
            label.setBounds(450,100,600,100);
            label.setText("想要選擇那位專家為你看病,請點(diǎn)擊相應(yīng)專家的姓名按鈕!");
            //添加三個文本框
            final Text text1=new Text(shell,SWT.WRAP);
            text1.setBounds(100,250,250,200);
            final Text text2=new Text(shell,SWT.WRAP);
            text2.setBounds(550,250,250,200);
            final Text text3=new Text(shell,SWT.WRAP);
            text3.setBounds(900,250,250,200);
            //添加按鈕1
            Button button1=new Button(shell,SWT.Activate);
            button1.setBounds(150,520,120,60);
            button1.setText("1號專家張三");
            //添加按鈕2
            Button button2=new Button(shell,SWT.Activate);
            button2.setBounds(600,520,120,60);
            button2.setText("2號專家李四");
            //添加按鈕3
            Button button3=new Button(shell,SWT.Activate);
            button3.setBounds(960,520,120,60);
            button3.setText("3號專家王五");
            //為按鈕1添加事件處理,事件處理內(nèi)容為“讀取病人的id和姓名,并將此病人添加到相應(yīng)專家的對立中”
            button1.addSelectionListener(new SelectionAdapter(){
                public void widgetSelected(SelectionEvent e)
                {
                    Patient pt=new Patient(patientList1.size()+1,"***");
                    patientList1.offer(pt);
                    text1.setText(pt.getNum()+"號病人,歡迎選擇1號專家為你坐診,請?jiān)诘群騾^(qū)等候,會有工作人員通過廣播通知你什么時候去看病");
                }
            });
            //為按鈕2添加事件處理
            button2.addSelectionListener(new SelectionAdapter(){
                public void widgetSelected(SelectionEvent e)
                {
                    Patient pt=new Patient(patientList2.size()+1,"****");
                    patientList2.offer(pt);
                    text2.setText(pt.getNum()+"號病人,歡迎選擇2號專家為你坐診,請?jiān)诘群騾^(qū)等候,會有工作人員通過廣播通知你什么時候去看病");
                }
            });
            //為按鈕3添加事件處理
            button3.addSelectionListener(new SelectionAdapter(){
                public void widgetSelected(SelectionEvent e)
                {
                    Patient pt=new Patient(patientList3.size()+1,"****");
                    patientList3.offer(pt);
                    text3.setText(pt.getNum()+"號病人,歡迎選擇3號專家為你坐診,請?jiān)诘群騾^(qū)等候,會有工作人員通過廣播通知你什么時候去看病");
                }
            });
            shell.layout();
            shell.open();
            while(!shell.isDisposed())
            {
                if(!display.readAndDispatch()){
                    display.sleep();
                }
            }
        }

    }

    **************************************************************************

    程序運(yùn)行結(jié)果如下:

    未命名

    //專家使用端

    package com.dr.hospitalQueueSystem;

    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.Label;
    import org.eclipse.swt.widgets.Shell;
    import org.eclipse.swt.widgets.Text;

    public class ProfessorUI {
        public static void main(String args[])
        {
            final Display display = Display.getDefault();
            final Shell shell = new Shell();
            shell.setMaximized(true);
            //初始化界面
            shell.setText("專家使用系統(tǒng)端");
            //服務(wù)器初始化
            HospitalQueueServer hq=new HospitalQueueServer();
            hq.Init();
            final Queue<Patient> qp1=hq.map.get(1);
            final Queue<Patient> qp2=hq.map.get(2);
            final Queue<Patient> qp3=hq.map.get(3);
            //添加文本控件
            final Text text1=new Text(shell,SWT.WRAP);
            text1.setBounds(100,250,250,200);
            text1.setFont(new Font(display,"宋體",15,SWT.BOLD));
            final Text text2=new Text(shell,SWT.WRAP);
            text2.setFont(new Font(display,"宋體",15,SWT.BOLD));
            text2.setBounds(550,250,250,200);
            final Text text3=new Text(shell,SWT.WRAP);
            text3.setFont(new Font(display,"宋體",15,SWT.BOLD));
            text3.setBounds(900,250,250,200);
            //添加按鈕1
            Button button1=new Button(shell,SWT.Activate);
            button1.setBounds(150,520,120,60);
            button1.setText("張三:下一個");
            //添加按鈕2
            Button button2=new Button(shell,SWT.Activate);
            button2.setBounds(600,520,120,60);
            button2.setText("李四:下一個");
            Button button3=new Button(shell,SWT.Activate);
            button3.setBounds(960,520,120,60);
            button3.setText("王五:下一個");
            //為按鈕1添加事件處理,事件處理內(nèi)容為“讀取病人的id和姓名,并將此病人添加到相應(yīng)專家的對立中”
            button1.addSelectionListener(new SelectionAdapter(){
                public void widgetSelected(SelectionEvent e)
                {
                    Patient pt=qp1.poll();
                    if(pt!=null)
                    {
                        text1.setText(pt.getName()+"請進(jìn)來");
                    }
                    else
                    {
                        text1.setText("暫時沒有病人了,您先休息會兒");
                    }
                }
            });
            //為按鈕2添加事件處理
            button2.addSelectionListener(new SelectionAdapter(){
                public void widgetSelected(SelectionEvent e)
                {
                    Patient pt=qp2.poll();
                    if(pt!=null)
                    {
                        text2.setText(pt.getName()+"請進(jìn)來");
                    }
                    else
                    {
                        text2.setText("暫時沒有病人了,您先休息會兒");
                    }
                }
            });
            //為按鈕3添加事件處理
            button3.addSelectionListener(new SelectionAdapter(){
                public void widgetSelected(SelectionEvent e)
                {
                    Patient pt=qp3.poll();
                    if(pt!=null)
                    {
                        text3.setText(pt.getName()+"請進(jìn)來");
                    }
                    else
                    {
                        text3.setText("暫時沒有病人了,您先休息會兒");
                    }
                }
            });
            shell.layout();
            shell.open();
            while (!shell.isDisposed()) {
                if (!display.readAndDispatch())
                    display.sleep();
            }
        }

    }

    ********************************************************************************************

    程序運(yùn)行結(jié)果如下:

    未命名

    這個程序還有許多缺點(diǎn)比如說數(shù)據(jù)冗余,沒有實(shí)現(xiàn)專家與病人之間的通信!

    由于沒有實(shí)現(xiàn)多線程技術(shù),在專家系統(tǒng)端運(yùn)行時,只能是調(diào)用服務(wù)器初始化的病人,不能調(diào)用病人系統(tǒng)端添加的病人。

    posted on 2010-10-31 19:52 馮魁 閱讀(295) 評論(0)  編輯  收藏


    只有注冊用戶登錄后才能發(fā)表評論。


    網(wǎng)站導(dǎo)航:
     

    導(dǎo)航

    統(tǒng)計(jì)

    公告

    快樂每一天!

    Everything is an object!

    常用鏈接

    留言簿(2)

    隨筆檔案

    學(xué)習(xí)網(wǎng)站

    搜索

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 久久精品国产亚洲AV无码偷窥| 久久综合给合久久国产免费| 亚洲午夜一区二区电影院| 亚洲情a成黄在线观看| 亚洲第一成年免费网站| a级黄色毛片免费播放视频| 国产精品亚洲专区无码WEB| 亚洲天堂一区在线| 亚洲AV日韩AV永久无码下载| 亚洲精品尤物yw在线影院| 日韩人妻无码免费视频一区二区三区 | 99久久免费精品视频| 精品国产污污免费网站入口| 国产成人高清亚洲一区久久| 国产亚洲精品bv在线观看| 亚洲色图.com| 亚洲国产精品婷婷久久| 亚洲乱色熟女一区二区三区丝袜| 亚洲第一区精品观看| 国产乱色精品成人免费视频| 性色av无码免费一区二区三区| 精品国产污污免费网站aⅴ| 久久99热精品免费观看牛牛| 亚洲国产午夜福利在线播放| 91在线视频免费看| 免费福利视频导航| 182tv免费观看在线视频| 久久综合九色综合97免费下载| a色毛片免费视频| 野花香在线视频免费观看大全 | 亚洲国产AV无码一区二区三区| 亚洲午夜精品一区二区公牛电影院 | 久久亚洲国产精品五月天| 亚洲啪啪综合AV一区| 亚洲熟妇av一区二区三区漫画| 亚洲高清视频一视频二视频三| 国产精品免费电影| 免费国产小视频在线观看| 国产成人精品123区免费视频| 日本免费电影一区| 免费亚洲视频在线观看|