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 阅读(129) 评论(0)  编辑  收藏

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


网站导航:
 
<2024年12月>
24252627282930
1234567
891011121314
15161718192021
22232425262728
2930311234

常用链接

留言簿(1)

文章档案(21)

搜索

  •  

最新评论

阅读排行榜

评论排行榜