[codeimport java.util.*;
public class ch52
{
public static void main(String args[]) throws BodyException
{
Car bus=new Car();
Car truck-new Car();
Car taxi=new Car();
truck.name="卡車";
truck.wheel=8;
truck.carry=3;
taxi.name="計程車";
taxi.wheel=4;
taxi.carry=5;
System.out.println(bus.name+"有"+bus.wheel+"個輪子,可載"+bus.carry+"人.");
System.out.println(truck.name+"有"+truck.wheel+"個輪子,可載"+truck.carry+"人.");
System.out.println(taxi.name+"有"+taxi.wheel+"個輪子,可載"+taxi.carry+"人.");
}
}
Class car
{
String name;
int wheel;
int carry;
}][/code]作者: 張峻瑋 時間: 2015-1-21 20:47