亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

新手java求指導

新手java求指導

慕粉1471134825 2017-04-15 13:31:48
System.out.println("歡迎使用達達租車系統");? ? System.out.println("您是否要租車:是1 ? 否0");? ? Scanner input = new Scanner (System.in);? ? int i=input.nextInt();? ? if (i==1){? ? System.out.println("您可租車的類型及其價目表:");? ? System.out.println("序號"+"\t"+"汽車名稱"+"\t"+"租金"+"\t"+"容量");? ? }else{? ? System.out.println("歡迎您再次光臨達達租車系統");? ? }? ? int j;? ? for (j=0;j<6;j++){? ? if (automobileMessenge[j] instanceof Car){? ? System.out.println(automobileMessenge[j].num+"\t"+automobileMessenge[j].name+"\t"? ? +automobileMessenge[j].rent+"元/天"+"\t"+"載人:"+((project7.Car) automobileMessenge[j]).getPeopleCount()+"人");? ? }? ? if (automobileMessenge[j] instanceof Trunk){? ? System.out.println(automobileMessenge[j].num+"\t"+automobileMessenge[j].name+"\t"? ? ? ? +automobileMessenge[j].rent+"元/天"+"\t"+"載貨:"+((project7.Trunk) automobileMessenge[j]).getThingCount()+"噸");? ? }? ? if (automobileMessenge[j] instanceof PickUp){? ? System.out.println(automobileMessenge[j].num+"\t"+automobileMessenge[j].name+"\t"+? ? automobileMessenge[j].rent+"元/天"+"\t"+"載人:"+((project7.PickUp) automobileMessenge[j]).getPeopleCount()? ? ? ? +"載貨:"+((project7.PickUp) automobileMessenge[j]).getThingCount()+"噸");? ? }? ? }? ? System.out.println("請輸入您要租車的數量");? ? int carTotal=input.nextInt();? ? int choice []=new int[carTotal];? ? for(j=0;j<carTotal;j++){? ? System.out.println("請輸入第"+""+(j+1)+"輛車的序號");? ? choice [j]=input.nextInt();? ? ? }現在想把choice數組循環并判斷是能載人的還是載貨的車 并輸出出來 實在沒思路了
查看完整描述

1 回答

?
Nirva_Troy

TA貢獻2條經驗 獲得超0個贊

http://www.xianlaiwan.cn/article/17523

看看這個,為什么不用類的繼承,

定義兩個子類,貨車和小汽車,覆寫下父類的方法就行了

查看完整回答
反對 回復 2017-04-15
  • 1 回答
  • 0 關注
  • 1369 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號