各位大神,请问我这样有没有体现多态性?
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();
}
}