第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

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

大佬看看 有什么要改的地方

Car頁

package?com;

public?abstract?class?Car?{
????protected?String?name;
????protected?int?price;
????protected?int?style;
????public?Car(int?style,String?name,int?price){
????????this.name=name;
????????this.price=price;
????????this.style=style;
????}
????public?abstract?void?showcars();



Truruck頁

package?com;

public?class?Truck?extends?Car{
????protected?int?weight;
????public?Truck(int?style,String?name,int?price,int?weight){
?????????super(style,name,price);
?????????this.weight=weight;
????}

????@Override
????public?void?showcars()?{
????????????System.out.println(this.name?+?"?"+this.price+"元/天"+"?載貨:"+this.weight+"噸");
????}
}

Bus頁

package?com;

public?class?Bus?extends?Car{
????protected?int?num;
????public?Bus(int?style,String?name,int?price,int?num){
????????super(style,name,price);
????????this.num=num;
????}

????@Override
????public?void?showcars()?{
????????System.out.println(this.name?+?"?"+this.price+"元/天"+"?載人:"+this.num+"人");
????}
}



Pickup頁

package?com;

public?class?Pickup?extends?Car{
????protected?int?weight;
????protected?int?num;
????public?Pickup(int?style,String?name,int?price,int?num,int?weight){
????????super(style,name,price);
????????this.num=num;
????????this.weight=weight;
????}

????@Override
????public?void?showcars()?{
????????System.out.println(this.name?+?"?"+this.price+"元/天"+"?載人:"+this.num+"?載貨:"+this.weight+"噸");
????}
}


main頁

package?com;

import?java.util.Scanner;

public?class?Test?{
????public?static?void?main(String[]?args)?{
????????Scanner?input?=?new?Scanner(System.in);
????????System.out.println("歡迎使用租車系統(tǒng),請(qǐng)問是否需要租車:1是?0否");
????????int?index?=?input.nextInt();
????????if?(index?==?1)?{
????????????Car[]?cars?=?{new?Bus(1,"奧迪A4",?500,?4),?new?Bus(1,"馬自達(dá)6",?400,?4),
????????????????????new?Bus(1,"金龍",?800,?20),new?Pickup(0,"皮卡雪",?450,?4,?2),
????????????????????new?Truck(2,"松花江",?400,?4),?new?Truck(2,"依維柯",?1000,?20)};

????????????System.out.println("您可租車的類型和價(jià)目表:");
????????????System.out.println("序號(hào)??汽車名稱??租金??容量");
????????????for?(int?i?=?1;?i?<=?cars.length;?i++)?{
????????????????System.out.print(i?+?"?");
????????????????cars[i?-?1].showcars();
????????????}
????????????System.out.println("請(qǐng)輸入需要的數(shù)量");
//????????????車輛數(shù)量
????????????int?carNum?=?input.nextInt();

//????????????可載人的車
????????????String?bus="";
//????????????載人數(shù)量
????????????int?nums=0;

//????????????載貨的車
????????????String?trunk="";
//????????????載貨重量
???????????int?weights=0;
//???????????總價(jià)
????????????int?allPrice=0;
????????????for?(int?i?=?1;?i?<=?carNum;?i++)?{
????????????????System.out.println("請(qǐng)輸入第"?+?i?+?"輛車的序號(hào)");
????????????????//車輛序號(hào)?carIndex-1
????????????????int?carIndex?=?input.nextInt();
????????????????if(cars[carIndex-1].style==0){
//????????????????????載人和載物的車
????????????????????nums+=((Pickup)?cars[carIndex-1]).num;
????????????????????weights+=((Pickup)?cars[carIndex-1]).weight;
????????????????????bus+="?"+cars[carIndex-1].name;
????????????????}else?if(cars[carIndex-1].style==1){
//????????????????????載人的車
????????????????????bus+="?"+cars[carIndex-1].name;
????????????????????nums+=((Bus)?cars[carIndex-1]).num;
????????????????}else?if(cars[carIndex-1].style==2){
//????????????????????載物的車
????????????????????trunk+="?"+?cars[carIndex-1].name;
????????????????????weights+=((Truck)?cars[carIndex-1]).weight;
????????????????}
????????????????allPrice+=cars[carIndex-1].price;
????????????}
????????????System.out.println("請(qǐng)輸入租車天數(shù)");
//????????????租車天數(shù)
????????????int?carDay?=?input.nextInt();
????????????allPrice*=carDay;
????????????System.out.println("您的賬單:");
????????????System.out.println("***可載人的車有:");
????????????System.out.println(bus+"?共載:"+nums+"人");
????????????System.out.println("***可載貨的車有:");
????????????System.out.println(trunk+"?共載:"+weights+"噸");
????????????System.out.println("***租車價(jià)格:"?+?allPrice+"元");
????????}
????}
}


正在回答

1 回答

問題就在Car頁,后面少了個(gè)大括號(hào)啊。是你沒復(fù)制過來?

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

舉報(bào)

0/150
提交
取消

大佬看看 有什么要改的地方

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

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

幫助反饋 APP下載

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

公眾號(hào)

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