Passionate1
2018-07-27 11:08
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);
}
}
是这样吗
if(nuber>300&&number<400)
{
}
else
{
}
。。。。。
好像是这样吧
如何用输入人数来筛选交通工具呢?
厉害厉害,this和super都用到了,真是学以致用
新手回答:可以啦。
main()里面,可以直接用new就好啦。
i,p,l都没有用到
Java入门第二季 升级版
530560 学习 · 6091 问题
相似问题