//父类
package com.imooc;
public class FuLei {
public String name;
public int person;
public String style;
public void act()
{
System.out.println("名字="+name+" "+"人数="+person+" "+"类型="+style);
}
}
//子类自行车
public class Bicycle extends FuLei {
public void act()
{
super.name="自行车";
super.person=2;
super.style="陆运";
super.act();
}
}
//子类汽车
public class Car extends FuLei {
public void act()
{
super.name="小汽车";
super.person=5;
super.style="陆运";
super.act();
}
}
//子类火车
public class Train extends FuLei {
public void act()
{
super.name="火车";
super.person=2000;
super.style="陆运";
super.act();
}
}
//子类轮船
public class stea extends FuLei{
public void act()
{
super.name="轮船";
super.person=20000;
super.style="海运";
super.act();
}
}
//子类飞机
public class aircraft extends FuLei {
public void act()
{
super.name="飞机";
super.person=500;
super.style="空运";
super.act();
}
}
//测试类
public class Demo {
public static void main(String [] sss)
{
FuLei obj1= new Bicycle();
obj1.act();
FuLei obj2= new Car();
obj2.act();
FuLei obj3= new Train();
obj3.act();
FuLei obj4= new stea();
obj4.act();
FuLei obj5= new aircraft();
obj5.act();
}
}