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

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

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

    隨筆 - 20  文章 - 57  trackbacks - 0
    <2010年10月>
    262728293012
    3456789
    10111213141516
    17181920212223
    24252627282930
    31123456

    常用鏈接

    留言簿(2)

    隨筆分類

    隨筆檔案

    文章分類

    文章檔案

    51CTO

    搜索

    •  

    最新評論

    閱讀排行榜

    評論排行榜


    ======================================================================================

    這僅僅是一個很簡單的醫院掛號系統,雖然涉及到一些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 閱讀(379) 評論(0)  編輯  收藏

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


    網站導航:
     
    主頁
    主站蜘蛛池模板: 亚洲片一区二区三区| 99热精品在线免费观看| 四虎成人精品在永久免费| 亚洲色大成网站www| 四虎影视www四虎免费| 亚洲a无码综合a国产av中文| 麻豆国产入口在线观看免费| 色综合久久精品亚洲国产| 又粗又硬又黄又爽的免费视频 | 产传媒61国产免费| 亚洲麻豆精品国偷自产在线91| 青青草97国产精品免费观看| 亚洲人成电影网站国产精品 | 中文字幕亚洲精品无码| 韩国免费三片在线视频| 深夜a级毛片免费无码| 亚洲中文字幕在线观看| 外国成人网在线观看免费视频| 亚洲欧洲在线播放| 精品少妇人妻AV免费久久洗澡| 无码 免费 国产在线观看91| 久久久久久a亚洲欧洲aⅴ| 最近2022中文字幕免费视频| 亚洲人成电影在线观看青青| 在线观看亚洲免费| a毛片在线免费观看| 精品亚洲AV无码一区二区 | 国产大片91精品免费观看男同| xxxxxx日本处大片免费看| 亚洲综合精品一二三区在线| 97无码免费人妻超级碰碰夜夜| 日本特黄特色AAA大片免费| 久久香蕉国产线看观看亚洲片| 国产1024精品视频专区免费| 免费国产va在线观看| 久久精品蜜芽亚洲国产AV| 免费黄色大片网站| 一区二区三区观看免费中文视频在线播放 | 免费又黄又爽又猛大片午夜 | 国产综合免费精品久久久| 亚洲国产成人精品无码区在线秒播 |