我就不吃芹菜

导航

 
 1 public class fulei {
 2     public fulei()
 3     {
 4         System.out.println("欢迎使用海尔");
 5     }
 6     public String Pinpai;
 7     public String Xinghao;
 8     public fulei(String pinpai, String xinghao)
 9     {
10         this.Pinpai = pinpai;
11         this.Xinghao = xinghao;
12         System.out.println(Pinpai+"饮水机\n"+"型号为"+Xinghao);
13     }
14     int t = 0;
15     public void reshui(int 时间)
16     {
17         t = 时间;
18         if(t > 15&&t<20)
19         {
20              System.out.println("保温");
21         }
22         else
23         {
24             System.out.println("加热");
25         }
26     }
27     public void xiaodu(int 时间1)
28     {
29         t = 时间1;
30         if(t >= 20)
31         {
32             System.out.println("消毒");
33         }
34     }
35 }
public class zilei1 extends fulei
{
    public zilei1 (String Pinpai, String Xinghao)
    {
        super (Pinpai, Xinghao);
    }
    public zilei1()
    {
        String Pinpai = "美的";
        String Xinghao = "HB350";
        System.out.println("我是"+Pinpai+Xinghao);
    }
    int t;
    public void xiaodu(int t)
    {
        if(t > 65)
        {
            System.out.println("正在消毒");
        }
    }
}
 1 public class test {
 2 
 3     public static void main(String[] args) {
 4         // TODO Auto-generated method stub
 5         fulei ysj1 = new fulei();
 6         fulei ysj = new fulei("Haier", "GB125");
 7             ysj.reshui(6);
 8             ysj.xiaodu(70);
 9             ysj.reshui(16);
10             
11         zilei1 ysj2 = new zilei1();
12             ysj2.xiaodu(70);
13             
14         //向上转型调用方法    
15             fulei ysj3 = new zilei1();
16             ysj3.xiaodu(80);
17     }
18 
19 }

posted on 2015-10-15 23:49  我就不吃芹菜  阅读(140)  评论(0编辑  收藏  举报