最近中文字幕高清中文字幕无,亚洲欧美高清一区二区三区,一本色道无码道dvd在线观看 ,一个人看的www免费高清中文字幕

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

請(qǐng)大神評(píng)價(jià)一下,還能優(yōu)化嗎

請(qǐng)大神評(píng)價(jià)一下,還能優(yōu)化嗎

woshishui1 2016-03-30 17:46:35
package com.imooc;import java.util.Scanner;public class Text { public static void main(String[] args) { // TODO Auto-generated method stub /*功能: 1、展示所有可租車輛 * ? ? ?2、選擇車型,租車量 * ? ? ?3、展示租車清單,包含:總金額、總載貨量及其車型、總載人量及其車型 *模型分析:1、數(shù)據(jù)模型分析 * ? ? ? ?2、業(yè)務(wù)模型分析 * 3、顯示和流程分析 */? ? ? ? Car[] carList={new Cathcar("東風(fēng)標(biāo)致",200,4),new Cathcar("沈陽卡龍",300,5),new Cathcar("重慶碉堡",400,10),? ? ? ?new Cathcar("廣東雪龍",550,12),new Camcar("迅達(dá)極致",650,16),new Camcar("粵運(yùn)朗日",780,36),new Camcar("雪佛蘭",900,4),? ? ? ?new Camcar("豐田",980,5),new pika("皮卡",280,2,650)};? ? ? ?System.out.println("歡迎使用租車系統(tǒng)!");//歡迎用戶使用? ? ? ?System.out.println("請(qǐng)問是否需要租車?需要回復(fù)1,不需要回復(fù)0");//提示用戶選擇菜單? ? ? ?Scanner input=new Scanner(System.in);? ? ? ?int recieve=input.nextInt();? ? ? ?if(recieve==1){? ? ? System.out.println("你可租車的類型及其價(jià)目表:");? ? ? System.out.println("序號(hào)\t汽車名稱\t租金\t\t容量");? ? ? //for(int i=0;i<carList.length;i++){? ? int i=1;? ? for(Car currentCar:carList){? ? if(currentCar instanceof Camcar)? ? ? System.out.println(i+"\t"+currentCar.name+"\t"+currentCar.rent+"/天"+"\t\t"+currentCar.manNum+"人"); ?? ? else if(currentCar instanceof Cathcar)? ? ? System.out.println(i+"\t"+currentCar.name+"\t"+currentCar.rent+"/天"+"\t\t"+currentCar.thingsNum+"噸");? ? ? ? ? ? ? else? ? ? ? ? ? ? System.out.println(i+"\t"+currentCar.name+"\t"+currentCar.rent+"/天"+"\t\t"+currentCar.manNum+"人"+"\t"+currentCar.thingsNum+"噸");? ? ? ? i++;? ? ? ? ? ? ? ?}? ? System.out.println("請(qǐng)輸入您要租汽車的數(shù)量:");? ? int rentNum=input.nextInt();? ? int[] count=new int[carList.length];? ? for(int j=0;j<rentNum;j++){? ? System.out.println("請(qǐng)輸入您租車的序號(hào):");? ? int rankCar=input.nextInt();? ? count[j]=rankCar;? ? rankCar=0;? ? }? ? System.out.println("請(qǐng)輸入租車的天數(shù):");? ? int days=input.nextInt(); //顯示汽車賬單? ? double num=0;? ? for(int k=0;k<rentNum;k++){? ? ? num=num+carList[count[k]-1].rent*days;? ? ? System.out.println("汽車名稱:" +carList[count[k]-1].name );? ? }? ? System.out.println(carList[count[rentNum]].name +"\t\t" + "總金額:"+ num + "\t\t" +"租車時(shí)間:" + days);? ? }else? ? System.out.println("退出系統(tǒng)!");? ? ? ? ? ? ? ? }
查看完整描述

2 回答

?
慕村9732791

TA貢獻(xiàn)1條經(jīng)驗(yàn) 獲得超0個(gè)贊

我是新手,感覺你這個(gè)算法流程寫的很巧妙,很棒,我自己是想不出來的。不過你這里只有主方法,看不到其他類的代碼。貌似類中的屬性沒有私有化吧,看你沒有使用到get方法,另外計(jì)算總金額的功能是否可以做成父類中的一個(gè)方法呢


查看完整回答
反對(duì) 回復(fù) 2016-05-08
?
qq___524

TA貢獻(xiàn)171條經(jīng)驗(yàn) 獲得超74個(gè)贊

不需要優(yōu)化了吧

查看完整回答
反對(duì) 回復(fù) 2016-04-19
  • 2 回答
  • 0 關(guān)注
  • 1479 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)