為甚么輸出的都是0?
public?class?Initail?{ public?static?void?main(String[]?args)?{ //?TODO?Auto-generated?method?stub int?i; Car[]?cars?=?{new?PersonCar(1,"奧迪A4",500,4),new?PersonCar(2,"馬自達6",400,4), new?PickUp(3,?"皮卡雪6",?450,?2,?4),new?PersonCar(4,?"金龍",?800,?20),new?GoodsCar(5,"松花江",?400,?4), new?GoodsCar(6,?"依科維",?1000,?20)}; System.out.println("歡迎適用達達租車系統(tǒng):)"); System.out.println("是否租車:租車輸入1,不租車輸入2"); Scanner?s?=?new?Scanner(System.in); i?=?s.nextInt(); if?(i==1)?{ System.out.println("您可租的車型及其價目表:"); System.out.println("序號?????汽車名稱??????????租金????????????容量"); for?(Car?car?:?cars)?{ System.out.println(car.getNumber()+"\t"+car.getName()+"\t"+car.getPrice()+"元/天"+"\t"+"載人:"+car.getPersoncapacity()+"人"+"載貨:"+car.getGoodscapacity()+"噸"); } }else{ System.out.println("歡迎使用!"); } } }
歡迎適用達達租車系統(tǒng):)
是否租車:租車輸入1,不租車輸入2
1
您可租的車型及其價目表:
序號 ? ? 汽車名稱 ? ? ? ? ?租金 ? ? ? ? ? ?容量
0 null 0元/天 載人:0人載貨:0噸
0 null 0元/天 載人:0人載貨:0噸
0 null 0元/天 載人:0人載貨:0噸
0 null 0元/天 載人:0人載貨:0噸
0 null 0元/天 載人:0人載貨:0噸
0 null 0元/天 載人:0人載貨:0噸
2017-04-02
System.out.println(car.getNumber()+"\t"+car.getName()+"\t"+car.getPrice()+"元/天"+"\t"+"載人:"+car.getPersoncapacity()+"人"+"載貨:"+car.getGoodscapacity()+"噸");
????????????}
你這里面的car都換成cars
2017-03-29
你把完整的代碼貼出來??!或者你斷點調(diào)試?。?/p>