posts - 17,  comments - 14,  trackbacks - 0
          package gov.school.environment;

          public class Environment {
              
              
          private int tem;
              
          private int hum;
              
          private int pre;
              
          private int noi;

              
          public int getHum() {
                  
          return hum;
              }


              
          public void setHum(int hum) {
                  
          this.hum = hum;
              }


              
          public int getPre() {
                  
          return pre;
              }


              
          public void setPre(int pre) {
                  
          this.pre = pre;
              }


              
          public int getNoi() {
                  
          return noi;
              }


              
          public void setNoi(int noi) {
                  
          this.noi = noi;
              }


              
          public int getTem() {
                  
          return tem;
              }


              
          public void setTem(int tem) {
                  
          this.tem = tem;
              }


          }

          package gov.school.environment;

          import java.util.Random;

          public class EnvironmentServer {
              
              
          public static Environment[] getEnvironment(){
                  Environment[] env
          =new Environment[4];
                  Random ran 
          = new Random();
                  
                  Environment temp
          =new Environment();
                  temp.setTem(ran.nextInt(
          50));
                  temp.setHum(ran.nextInt(
          100));
                  temp.setPre(ran.nextInt(
          1000));
                  temp.setNoi(ran.nextInt(
          100));
                  env[
          0= temp;
                  
                  Environment temp1
          =new Environment();
                  temp1.setTem(ran.nextInt(
          50));
                  temp1.setHum(ran.nextInt(
          100));
                  temp1.setPre(ran.nextInt(
          1000));
                  temp1.setNoi(ran.nextInt(
          100));
                  env[
          1= temp1;
                  
                  Environment temp2
          =new Environment();
                  temp2.setTem(ran.nextInt(
          50));
                  temp2.setHum(ran.nextInt(
          100));
                  temp2.setPre(ran.nextInt(
          1000));
                  temp2.setNoi(ran.nextInt(
          100));
                  env[
          2= temp2;
                  
                  Environment temp3
          =new Environment();
                  temp3.setTem(ran.nextInt(
          50));
                  temp3.setHum(ran.nextInt(
          100));
                  temp3.setPre(ran.nextInt(
          1000));
                  temp3.setNoi(ran.nextInt(
          100));
                  env[
          3= temp3;
                  
                  
          return env;
                  
              }

              
          }

          package gov.school.environment;

          public class EnvironmentClient {
              
          public static void main(String[] args)
              
          {
                  
          while(true)
                  
          {
                      Environment envi[]
          =EnvironmentServer.getEnvironment();
                      
          for(int l=0;l<envi.length;l++)
                      
          {
                          System.out.println(
          ""+(l+1)+"號廳:  "+envi[l].getTem()+"℃   ***"+envi[l].getHum()+"% ***"+envi[l].getPre()+"Pa***"+envi[l].getNoi()+"Bd");
                      }

                      
          for(int l=0;l<envi.length;l++)
                      
          {
                          
          if (envi[l].getTem()>30)
                          
          {
                              System.out.println((l
          +1)+"號廳溫度過高!");
                          }

                          
          if (envi[l].getHum()>80)
                          
          {
                              System.out.println((l
          +1)+"號廳濕度過高!");
                          }

                          
          if (envi[l].getPre()>800)
                          
          {
                              System.out.println((l
          +1)+"號廳氣壓過高!");
                          }

                          
          if (envi[l].getNoi()>80)
                          
          {
                              System.out.println((l
          +1)+"號廳噪音過高!");
                          }

                          
                      }

                      System.out.println(
          "\n");
                          
          try
                          
          {
                              Thread.sleep(
          1000*10);
                          }

                          
          catch(InterruptedException e)
                          
          {
                              e.printStackTrace();
                              
          break;
                          }

                  }

              }


          }

          posted on 2010-10-10 18:17 Mineralwasser 閱讀(140) 評論(0)  編輯  收藏

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


          網站導航:
           
          <2025年7月>
          293012345
          6789101112
          13141516171819
          20212223242526
          272829303112
          3456789

          常用鏈接

          留言簿(1)

          文章檔案(21)

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 娄烦县| 德惠市| 蓬安县| 波密县| 徐闻县| 手机| 依安县| 曲松县| 香港 | 新津县| 会东县| 富川| 固阳县| 天气| 喀什市| 凌海市| 揭阳市| 汕尾市| 麻城市| 雅安市| 汶上县| 宜春市| 石城县| 闵行区| 三门峡市| 嘉禾县| 綦江县| 额济纳旗| 措勤县| 玉山县| 鄯善县| 西乡县| 樟树市| 武山县| 井冈山市| 镇远县| 武强县| 南昌县| 汉沽区| 江陵县| 中方县|