大佬们看看我写的行吗
package com.exc;
class TrafficTools{
int num = 1;
String way = "地奔";
public void VWay() {
System.out.println("出行方式是:" + way + " 承载人数为" + num + "人。");
}
}
class Bus extends TrafficTools{
int num = 40;
String way = "公交车";
@Override
public void VWay() {
System.out.println("出行方式是:" + way + " 承载人数为" + num + "人。");
}
}
class Plane extends TrafficTools{
int num = 100;
String way = "飞机";
@Override
public void VWay() {
System.out.println("出行方式是:" + way + " 承载人数为" + num + "人。");
}
}
class Ship extends TrafficTools{
int num = 400;
String way = "轮船";
@Override
public void VWay() {
System.out.println("出行方式是: " + way + " 承载人数为" + num + "人。");
}
}
public class Tests {
public static void main(String[] args) {
TrafficTools tTools = new TrafficTools();
TrafficTools tools1 = new Bus();
TrafficTools tools2 = new Plane();
TrafficTools tools3 = new Ship();
tTools.VWay();
tools1.VWay();
tools2.VWay();
tools3.VWay();
}
}