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

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

借鑒了其他同學(xué)的寫了半天呢 還是不熟悉

標(biāo)簽:
Java

父类
package car;

public abstract class Car{
protected int price;//车的租金
protected String name;//车的名字
protected int passengerLoad;//载人数量
protected double goodsLoad;//载货重量

public int getPrice(){
    return price;
}

public void setPrice(int price){//执行方法
    this.price=price;
}
public String getName(){
    return name;
}
public void setName(String name){
    this.name=name;
}
public int getPassengerLoad(){
    return passengerLoad;
}
public void setpassengerLoad(int passengerLoad){
    this.passengerLoad=passengerLoad;

}
public double getGoodsLoad(){
    return goodsLoad;
}
public void setgoodsLoad(double goodsLoad){
    this.goodsLoad=goodsLoad;
}

}
客车
package car;

public class keCar extends Car {
public keCar (String name,int price,double goodsLoad,int passengerLoad){
this.setName(name);
this.setPrice(price);
this.setpassengerLoad(passengerLoad);

}

public String toString(){
return this.getName()+"----"+this.getPrice()+"元/天----载客"+this.getPassengerLoad()+"人";
}
}
货车
public class truck extends Car{
public truck(String name,int price,double goodsLoad,int passengerLoad){
this.setName(name);
this.setPrice(price);
this.setgoodsLoad(goodsLoad);

}

public String toString(){
return this.getName()+"----"+this.getPrice()+"元/天----载客"+this.getGoodsLoad()+"货";

}
}
两用
public class bothCarry extends Car{
public bothCarry (String name,int price,double goodsLoad,int passengerLoad){
this.setName(name);
this.setPrice(price);
this.setpassengerLoad(passengerLoad);
this.setgoodsLoad(goodsLoad);
}
public String toString(){
return this.getName()+"----"+this.getPrice()+"元/天----载客"+this.getPassengerLoad()+"人"+this.getGoodsLoad()+"货";

}
}
test
public class text {

public static void main(String[] args) {
    // TODO Auto-generated method stub

Scanner sc=new Scanner(System.in);
System.out.println("欢迎使用答答租车系统");
System.out.println();
System.out.println("租车请按(1) 推出请按(0)");
int num=sc.nextInt();
Car[] cars={new keCar("奥迪A4",300,0,4),
new keCar("雪佛兰5",250,0,4),
new keCar("宝骏巴士",800,0,45),
new truck("东风R1",1000,10,0),
new truck("依维柯S",1500,25,0),
new bothCarry("皮卡雪Z",600,5,2)};
if(num!=1){
System.out.println("
欢迎下次光临**");
System.exit(0);
}else{

    System.out.println("请输入你要预订的数量") ;
  }

    int priceSum=0;
double goodsLoadSum=0;
    int passengerLoadSum=0;
    int i=sc.nextInt();
    for(int j=1;j<=i;j++){
        System.out.println("请输入第"+j+"辆要预订车辆的序号");

        int id=sc.nextInt();
        passengerLoadSum=passengerLoadSum+cars[id-1].getPassengerLoad();
        goodsLoadSum=goodsLoadSum+cars[id-1].getGoodsLoad();
        priceSum=priceSum+cars[id-1].getPrice();

    }
    System.out.println("请输入租车天数");
    int day=sc.nextInt();
    priceSum=priceSum*day;

    System.out.println("您的账单:");
    System.out.println("共租车"+i+"辆,"+"共租车"+day+"天");
    System.out.println("一共可载"+passengerLoadSum+"人,"+"共可载"+goodsLoadSum+"吨");
    System.out.println("总价格"+priceSum+"元"); 

    sc.close();

System.out.println("谢谢惠顾");
}

}

點(diǎn)擊查看更多內(nèi)容
1人點(diǎn)贊

若覺得本文不錯(cuò),就分享一下吧!

評(píng)論

作者其他優(yōu)質(zhì)文章

正在加載中
感謝您的支持,我會(huì)繼續(xù)努力的~
掃碼打賞,你說多少就多少
贊賞金額會(huì)直接到老師賬戶
支付方式
打開微信掃一掃,即可進(jìn)行掃碼打賞哦
今天注冊(cè)有機(jī)會(huì)得

100積分直接送

付費(fèi)專欄免費(fèi)學(xué)

大額優(yōu)惠券免費(fèi)領(lǐng)

立即參與 放棄機(jī)會(huì)
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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

舉報(bào)

0/150
提交
取消