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 閱讀(141) 評論(0)  編輯  收藏

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


          網站導航:
          博客園   IT新聞   Chat2DB   C++博客   博問  
           
          <2025年7月>
          293012345
          6789101112
          13141516171819
          20212223242526
          272829303112
          3456789

          常用鏈接

          留言簿(1)

          文章檔案(21)

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 游戏| 新沂市| 新河县| 喀喇| 墨竹工卡县| 多伦县| 麻栗坡县| 固镇县| 丰镇市| 垦利县| 息烽县| 鸡泽县| 东乌珠穆沁旗| 梓潼县| 阿克| 克什克腾旗| 林周县| 永寿县| 宾阳县| 浪卡子县| 阳城县| 阜平县| 丽江市| 西乡县| 金溪县| 梨树县| 宜宾县| 深圳市| 盱眙县| 城市| 泾阳县| 海伦市| 星座| 邹平县| 临漳县| 南昌县| 剑河县| 和硕县| 集贤县| 高州市| 英超|