未来的未来_
2015-06-10 11:32
package com.zp.duotai;
class Vehicle{
public void Function() {
// System.out.println("交通工具");
}
}
class Airplane extends Vehicle{
String name="飞机";
int number=500;
String way="air";
public void Function() {
System.out.println("交通工具:"+name+",载客人数:"+number+"人,运行方式:"+way);
}
}
class Ship extends Vehicle{
String name="轮船";
int number=200;
String way="water";
public void Function() {
System.out.println("交通工具:"+name+",载客人数:"+number+"人,运行方式:"+way);
}
}
class Bus extends Vehicle{
String name="公交车";
int number=40;
String way="road";
public void Function() {
System.out.println("交通工具:"+name+",载客人数:"+number+"人,运行方式:"+way);
}
}
public class jiaotonggongju {
public static void main(String[] args) {
Vehicle air = new Airplane();
Vehicle bus = new Bus();
Vehicle ship = new Ship();
air.Function();
bus.Function();
ship.Function();
}
}
我把你的代码复制到eclipse运行public class jiaotonggongju这一行也会报错啊
你这是重写
可以算是
Java入门第二季 升级版
530559 学习 · 6091 问题
相似问题