返回列表 發帖
  1. package kao;

  2. public class Main
  3. {
  4.         public static void main(String[] args)
  5.         {
  6.                 Car bus = new Car();
  7.                 bus.carname="公車";
  8.                 bus.wheels=6;
  9.                 bus.people=40;
  10.                 System.out.printf("%s有%d個輪子,可載%d個人\r\n",bus.carname,bus.wheels,bus.people);
  11.                 Car truck = new Car();
  12.                 truck.carname="卡車";
  13.                 truck.wheels=8;
  14.                 truck.people=3;
  15.                 System.out.printf("%s有%d個輪子,可載%d個人\r\n",truck.carname,truck.wheels,truck.people);
  16.                 Car taxi = new Car();
  17.                 taxi.carname="計程車";
  18.                 taxi.wheels=4;
  19.                 taxi.people=5;
  20.                 System.out.printf("%s有%d個輪子,可載%d個人\r\n",taxi.carname,taxi.wheels,taxi.people);
  21.         }
  22. }
複製代碼

TOP

返回列表