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

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

在幫助下,完成了練習(xí)。

package com.imooc;

import java.util.Scanner;


public class Initial {


public static void main(String[] args) {

// TODO Auto-generated method stub

System.out.println("歡迎使用租車系統(tǒng)\n您是否要租車?1-是,0-否");

Scanner input=new Scanner(System.in);

int isRent=input.nextInt();

double allrent=0;

double allloadage=0;

? ? int allseats=0;

if(isRent==1) {

System.out.println("您可租車的類型和價(jià)目表:");

System.out.println("序號(hào)? ? 汽車名稱? ? 租金? ? 容量");

Car[] cars= {

new Sedan("哈弗",200,5),

new Sedan("雪佛蘭",240,5),

new PickUp("本田",400,3,800.5),

new PickUp("豐田",450,3,1000.5),

new Truck("東風(fēng)",600,3000),

new Truck("五菱",650,3500)

};

for (int i=0;i<cars.length;i++)

{

int index=i+1;

if(cars[i] instanceof Sedan)

{

Sedan car=(Sedan)cars[i];//強(qiáng)制類型轉(zhuǎn)換

System.out.println(index+"? "+car.CarName+"? "+

car.Rent+"元/天"+" "+"載人: "+car.getSeats()+"人 ");

}

else if(cars[i] instanceof Truck)

{

Truck car=(Truck)cars[i];

System.out.println(index+"? "+car.CarName+"? "+

car.Rent+"元/天"+" "+"載貨:"+car.getLoadage()+"kg");

}

else

{

PickUp car=(PickUp)cars[i];

System.out.println(index+"? "+car.CarName+"? "+

car.Rent+"元/天"+" "+"載人: "+car.getSeats()+"人 "+" 載貨:"+car.getLoadage()+"kg");

}

}

System.out.println("請輸入您想要的租賃的車輛數(shù)目:");

int carsnum=input.nextInt();

Car[] chooseCar=new Car[carsnum];

for(int i=0;i<carsnum;i++) {

int num=i+1;

System.out.println("請選擇第"+num+"輛車:");

int whichcar=input.nextInt();

if (whichcar<=cars.length&& whichcar>0)

{

chooseCar[i]=cars[whichcar-1];

}

else {

System.out.println("請輸入正確的車輛序號(hào).\n");

i--;

continue;

}

}

System.out.println("您一共租了"+carsnum+"輛車");

System.out.println("分別是:");

for(int i=0;i<carsnum;i++)

{

System.out.println((i+1)+":"+chooseCar[i].getCarName());

}

? ??

for(int i=0;i<carsnum;i++)

{

if(chooseCar[i] instanceof Sedan)

{

Sedan car=(Sedan)chooseCar[i];

allrent+=car.getRent();

? ? allseats+=car.getSeats();

}

else if(chooseCar[i] instanceof Truck)

{

Truck car=(Truck)chooseCar[i];

allrent+=car.getRent();

allloadage+=car.getLoadage();

}

else

{

PickUp car =(PickUp)chooseCar[i];

allrent+=car.getRent();

allseats+=car.getSeats();

allloadage+=car.getLoadage();

}

}

System.out.println("一共能載:"+allloadage+"kg貨物,能載"+allseats+"人.");

System.out.println("一共需要:"+allrent+"元/天.\n");

System.out.println("請輸入租賃天數(shù):");

int days=input.nextInt();

System.out.println("您一共租賃"+days+"天,租金是:"+allrent*days+"元.");

}

}


}



正在回答

6 回答

我也懵逼了

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

Car[] cars= {

new Sedan("哈弗",200,5),

new Sedan("雪佛蘭",240,5),

new PickUp("本田",400,3,800.5),

new PickUp("豐田",450,3,1000.5),

new Truck("東風(fēng)",600,3000),

new Truck("五菱",650,3500)

};


朋友 能不能解釋下,這段是什么意思,前面有那一課有教過嗎

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

package com.imooc;


/*

?* 皮卡,既能載貨又能載人。

?*/

public class PickUp extends Car {

protected int seats;

protected double Loadage;

public PickUp(String CarName,double Rent,int seats,double Loadage) {

super(CarName,Rent);

this.seats=seats;

this.Loadage=Loadage;

}

public int getSeats() {

return this.seats;

}

public double getLoadage() {

return this.Loadage;

}


}



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

package com.imooc;


/*

?* 貨車

?*/

public class Truck extends Car {

protected double Loadage;

public Truck(String CarName,double Rent,double Loadage) {

super(CarName,Rent);

this.Loadage=Loadage;

}

public double getLoadage() {

return this.Loadage;

}

}


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

package com.imooc;


/*

?* 載人汽車

?*/

public class Sedan extends Car {

protected int seats;

public Sedan(String CarName,double Rent,int seats) {

super(CarName,Rent);

this.seats=seats;

}

public int getSeats() {

return this.seats;

}

}



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

package com.imooc;


public? class Car {

protected String CarName;

protected double Rent;

public Car(String CarName,double Rent) {

this.CarName=CarName;

this.Rent=Rent;

}

public String getCarName() {

return this.CarName;

}

public Double getRent() {

return this.Rent;

}

}



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

qq__8737

為什么不用private
2020-03-22 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消
Java入門第二季 升級(jí)版
  • 參與學(xué)習(xí)       531098    人
  • 解答問題       6280    個(gè)

課程升級(jí)!以終為始告別枯燥,在開發(fā)和重構(gòu)中體會(huì)Java面向?qū)ο缶幊痰膴W妙

進(jìn)入課程

在幫助下,完成了練習(xí)。

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

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

幫助反饋 APP下載

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

公眾號(hào)

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