public class Trans {
public String name;
public String way;
public int person;
public void show() {
System.out.println("交通工具的载客人数:"); }}
public class Bus extends Trans{
public void show() {
name="公共汽车";
person=50;
way="陆地行走";
System.out.println(name+"在"+way+"上运输人数为:"+person); }}
public class Airplane extends Trans{
public void show() {
name="飞机";
way="天空飞行";
person=60;
System.out.println(name+"在"+way+"上运输人数为:"+person); }}
public class Ship extends Trans{
public void show() {
name="轮船";
way="海洋航行";
person=200;
System.out.println(name+"在"+way+"上运输人数为:"+person); }}
public class Test {
public static void main(String[] args) {
Trans t=new Trans();
Trans t1=new Bus();
Trans t2=new Airplane();
Trans t3=new Ship();
t.show();
t1.show();
t2.show();
t3.show(); }}