package com.imooc;
public class Transportation {
public int site;//载客数
public String transMode;//运送方式
public void operation(){
}
}
package com.imooc;
public class Aircraft extends Transportation {
int site=150;
String transMode="fly";
public void operation(){
System.out.println("飞机可载客"+site+"人,运送方式为"+transMode);
}
}
package com.imooc;
public class Steamship extends Transportation {
int site=200;
String transMode="water";
public void operation(){
System.out.println("轮船可载客"+site+"人,运送方式为"+transMode);
}
}
package com.imooc;
public class Bus extends Transportation {
int site=40;
String transMode="land";
public void operation(){
System.out.println("巴士可载客"+site+"人,运送方式为"+transMode);
}
}
package com.imooc;
public class Train extends Transportation {
int site=1500;
String transMode="land";
public void operation(){
System.out.println("火车可载客"+site+"人,运送方式为"+transMode);
}
}
package com.imooc;
public class Rickshaw extends Transportation {
int site=1;
String transMode="land";
public void operation(){
System.out.println("黄包车可载客"+site+"人,运送方式为"+transMode);
}
}
package com.imooc;
import java.util.Scanner;
public class Initial {
public static void main(String[] args) {
Transportation t1=new Aircraft();
Transportation t2=new Steamship();
Transportation t3=new Bus();
Transportation t4=new Train();
Transportation t5=new Rickshaw();
Scanner input =new Scanner(System.in);
System.out.println("请输入查询的对象:");
String Name=input.next();
String a="Aircraft";
String b="Steamship";
String c="Bus";
String d="Train";
String e="Rickshaw";
if(Name.equals(a)){
t1.operation();
}else if(Name.equals(b)){
t2.operation();
}else if(Name.equals(c)){
t3.operation();
}else if(Name.equals(d)){
t4.operation();
}else if(Name.equals(e)){
t5.operation();
}else{
System.out.println("!请检查输入的对象名称");
}
}
}