问答详情
源自:10-1 Java 中的多态

作业是这样吗

package com.imooc;


public class vehicle {

 String vehicles;

 String  way;

 int number;

 public vehicle(String vehicles,String way,int number) {

this.vehicles=vehicles;

this.way=way;

this.number=number;

System.out.println(vehicles+"可以在"+way+"运输"+number+"人");

 }

}



package com.imooc;


public class bus extends vehicle {


public bus(String vehicles, String way, int number) {

super(vehicles, way, number);

// TODO Auto-generated constructor stub

}


}


package com.imooc;


public class boat extends vehicle {


public boat(String vehicles, String way, int number) {

super(vehicles, way, number);

// TODO Auto-generated constructor stub

}


}


package com.imooc;


public class Plane extends vehicle {


public Plane(String vehicles, String way, int number) {

super(vehicles, way, number);

// TODO Auto-generated constructor stub

}


}


package com.imooc;


public class fangfa {


public static void main(String[] args) {


vehicle i=new bus("汽车", "陆地", 40);

vehicle p=new boat("轮船", "海洋", 300);

vehicle l=new Plane("飞机", "空中", 100);

}


}

是这样吗


提问者:Passionate1 2018-07-27 11:08

个回答

  • DF10F0001A
    2018-08-14 18:55:28

    if(nuber>300&&number<400)

    {

    }

    else

    {

    }

    。。。。。

    好像是这样吧

  • 霸道小王子
    2018-08-12 23:03:45

    如何用输入人数来筛选交通工具呢?

  • 无敌三角猫
    2018-08-01 16:39:16

    厉害厉害,this和super都用到了,真是学以致用

  • 芥子晴空
    2018-07-29 11:39:27

    新手回答:可以啦。

    main()里面,可以直接用new就好啦。

    i,p,l都没有用到