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)!");? ? ? ? ? ? ? ? }
請(qǐng)大神評(píng)價(jià)一下,還能優(yōu)化嗎
woshishui1
2016-03-30 17:46:35