- package bbs.istak.org.tw;
- public class Main {
- public static void main(String[] args) {
- Car bus = new Car();
- bus.carname="公車";
- bus.wheels=6;
- bus.people=40;
- System.out.printf("%s有%d個輪子,可載%d個人\r\n",bus.carname,bus.wheels,bus.people);
- Car truck = new Car();
- truck.carname="卡車";
- truck.wheels=8;
- truck.people=3;
- System.out.printf("%s有%d個輪子,可載%d個人\r\n",truck.carname,truck.wheels,truck.people);
- Car taxi = new Car();
- taxi.carname="計程車";
- taxi.wheels=4;
- taxi.people=5;
- System.out.printf("%s有%d個輪子,可載%d個人\r\n",taxi.carname,taxi.wheels,taxi.people);
- }
- }
複製代碼 |