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

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

第二季項(xiàng)目代碼,請(qǐng)大家們指教,蟹蟹泥萌。

package?dadaCarRental;

import?java.util.Scanner;

public?class?DadaTest?{
????????
????public?static?void?main(String[]?args)?{
????????//Vehicle?→?Object(assignment)?→?Arrays
????????Vehicle?[]?vehicles?=?new?Vehicle[6];
????????vehicles?[0]?=?new?Vehicle("奧迪A4",4,0,500);
????????vehicles?[1]?=?new?Vehicle("馬自達(dá)6",4,0,400);
????????vehicles?[2]?=?new?Vehicle("皮卡雪6",4,2,450);
????????vehicles?[3]?=?new?Vehicle("金龍",20,0,800);
????????vehicles?[4]?=?new?Vehicle("松花江",0,4,400);
????????vehicles?[5]?=?new?Vehicle("依維柯",0,20,1000);
????????//test:System.out.println(vehicles[3].price);
????????
????????//welcome.
????????System.out.println("*****歡迎使用達(dá)達(dá)租車系統(tǒng)*****");
????????System.out.println("您是否要租車:1是?0?否");
????????
????????//Input?user's?choise.
????????Scanner?input?=?new?Scanner(System.in);
????????int?inputNum1?=?input.nextInt();
????????
????????//Judge?and?feedback?sth.
????????if(inputNum1?==?1){
????????????System.out.println("*****您可租車的類型及其價(jià)目表*****");
????????????System.out.println("序號(hào)"?+?"????"?+?"汽車名稱?"?+?"????????"?+?"租金"?+?"????"?+?"容量");
????????????for(int?i=0;?i<6;?i++){
????????????????System.out.print(i+1+"、???????"+vehicles[i].name?+?"????????"?+vehicles[i].price?+?"????");
????????????????vehicles[i].action(vehicles[i].passangersNum,?vehicles[i].cargoNum);
????????????????System.out.print("\n");
????????????}
????????????
????????????//Start?to?rent.
????????????System.out.println("請(qǐng)輸入您要租車的數(shù)量:");
????????????int?inputNum2?=?input.nextInt();
????????????int?totalPrice?=?0;
????????????int?totalP?=?0;
????????????int?totalC?=?0;
????????????int?pIndex?=?0;
????????????int?cIndex?=?0;
????????????
????????????//set?string?arrays?to?store?names.?
????????????String?[]?pVehicles?=?new?String[inputNum2];
????????????String?[]?cVehicles?=?new?String[inputNum2];
????????????
????????????????//Input?and?record?the?detils.
????????????????for(int?i=1;?i<=?inputNum2;?i++){
????????????????????System.out.println("請(qǐng)輸入第"?+?i?+?"輛車的序號(hào)");
????????????????????int?carIndex?=?input.nextInt();
????????????????????if(carIndex<=0?||?carIndex>=7){
????????????????????????System.out.println("你輸錯(cuò)序號(hào)辣,重頭再來(lái)吧!╮(╯_╰)╭");
????????????????????????break;
????????????????????}
????????????????????
????????????????????totalPrice?=?totalPrice?+?vehicles[carIndex-1].price;
????????????????????
????????????????????if(vehicles[carIndex-1].passangersNum?!=0){
????????????????????????totalP?=?totalP?+?vehicles[carIndex-1].passangersNum;
????????????????????????pVehicles[pIndex]?=?vehicles[carIndex-1].name;
????????????????????????pIndex?=?pIndex?+?1?;
????????????????????}
????????????????????if(vehicles[carIndex-1].cargoNum?!=0){
????????????????????????totalC?=?totalC?+?vehicles[carIndex-1].cargoNum;
????????????????????????cVehicles[cIndex]?=?vehicles[carIndex-1].name;
????????????????????????cIndex?=?cIndex?+?1?;
????????????????????}
????????????????}
????????????
????????????//Print?the?bill?and?info.
????????????if(totalPrice?!=0?){
????????????????System.out.println("*****您的賬單*****");
????????????????System.out.println("總價(jià):"+totalPrice+"元"+"\n");
????????????
????????????????System.out.print("可載人的車:");
????????????????if(totalP!=0){
????????????????????System.out.print("(可載"+totalP+"人)"+"\n");
????????????????????for(int?i?=?0;?i<pIndex;?i++?){
????????????????????????System.out.print(pVehicles[i]+"????");
????????????????????}
????????????????}else{
????????????????????System.out.println("根本沒(méi)有租辣!"+"\n");
????????????????}
????????????
????????????????System.out.print("\n"+"可載貨的車:");
????????????????if(totalC!=0){
????????????????????System.out.print("(可載"+totalC+"噸)"+"\n");
????????????????????????for(int?i?=?0;?i<cIndex;?i++){
????????????????????????????System.out.print(cVehicles[i]+"????");
????????????????????????}
????????????????}else{
????????????????????System.out.print("根本沒(méi)有租辣!");
????????????????????}
????????????????
????????????}else{
????????????????System.out.println("而且你要支付我咨詢費(fèi)100塊!");
????????????????}
????????????
????????}else?if(inputNum1?==?0){
????????????System.out.println("好吧。。。白白!");
????????}else{
????????????System.out.println("按錯(cuò)辣!╮( ̄⊿ ̄)╭!粗去重新來(lái)!");
????????}
????????
????????}????
????}

class?Vehicle?{
????String?name;
????int?passangersNum;
????int?cargoNum;
????int?price;
????
????//set?the?initial?paramater.
????Vehicle(String?vName,int?pNum,int?cNum,int?vPrice){
????????name?=?vName;
????????passangersNum?=?pNum;
????????cargoNum?=?cNum;
????????price?=?vPrice;
????};
????
????//judge?what?it?carrys.
????void?action(int?pnum,int?cnum){
????????if(pnum?!=?0){
????????????System.out.print("載客:"?+?pnum?+?"人");
????????}
????????if(cnum?!=?0){
????????????System.out.print("載貨"+?cnum?+?"噸");
????????}
????}
}


正在回答

1 回答

第一次寫(xiě)項(xiàng)目,自己分析自己的一些問(wèn)題:

1、沒(méi)有再去劃分子類,直接用父類。

2、如果選車環(huán)節(jié),隨便無(wú)序輸入序號(hào)的話,最后的車型輸出會(huì)很難看。打算后面用數(shù)組來(lái)解決。

3、沒(méi)有解決如果輸錯(cuò)序號(hào)或量后怎么重新輸入的問(wèn)題。

4、封裝、繼承、多態(tài)和接口都沒(méi)有使用,對(duì)此重要概念運(yùn)用不熟練。寫(xiě)的不像是面向?qū)ο蠖敲嫦蜻^(guò)程的語(yǔ)言。


以上,還請(qǐng)大腿們多多賜教,蟹蟹。

0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

第二季項(xiàng)目代碼,請(qǐng)大家們指教,蟹蟹泥萌。

我要回答 關(guān)注問(wèn)題
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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