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

為了賬號安全,請及時綁定郵箱和手機立即綁定

大佬交作業(yè)啦,不服來看。

//?Car.java
public?class?Car?{
????public?String?name;
????public?int?rent_money;
????public?int?capacity_person;
????public?int?capacity_goods;

????public?Car(String?name,?int?rent_money,?int?capacity_person,?int?capacity_goods)?{
????????this.name?=?name;
????????this.rent_money?=?rent_money;
????????this.capacity_person?=?capacity_person;
????????this.capacity_goods?=?capacity_goods;
????}

????public?String?getName()?{
????????return?name;
????}

????public?void?setName(String?name)?{
????????this.name?=?name;
????}

????public?int?getRent_money()?{
????????return?rent_money;
????}

????public?void?setRent_money(int?rent_money)?{
????????this.rent_money?=?rent_money;
????}

????public?int?getCapacity_person()?{
????????return?capacity_person;
????}

????public?void?setCapacity_person(int?capacity_person)?{
????????this.capacity_person?=?capacity_person;
????}

????public?int?getCapacity_goods()?{
????????return?capacity_goods;
????}

????public?void?setCapacity_goods(int?capacity_goods)?{
????????this.capacity_goods?=?capacity_goods;
????}
}
//?SmallCar.java
public?class?SmallCar?extends?Car?{
????public?SmallCar(String?name,?int?rent_money,?int?capacity_person,?int?capacity_goods)?{
????????super(name,?rent_money,?capacity_person,?capacity_goods);
????}
}
//?Bus.java
public?class?Bus?extends?Car?{
????public?Bus(String?name,?int?rent_money,?int?capacity_person,?int?capacity_goods)?{
????????super(name,?rent_money,?capacity_person,?capacity_goods);
????}
}
//?Pick.java
public?class?Pick?extends?Car?{
????public?Pick(String?name,?int?rent_money,?int?capacity_person,?int?capacity_goods)?{
????????super(name,?rent_money,?capacity_person,?capacity_goods);
????}
}
//?Truck.java
public?class?Truck?extends?Car?{
????public?Truck(String?name,?int?rent_money,?int?capacity_person,?int?capacity_goods)?{
????????super(name,?rent_money,?capacity_person,?capacity_goods);
????}
}
//?Test.java
import?java.util.Scanner;

public?class?Test?{
????public?static?void?main(String[]?args)?{
????????System.out.println("歡迎使用噠噠租車系統(tǒng):");
????????System.out.println("您是否需要租車:1是?0否");

????????int?is_rent?=?0;?//?是否租車
????????is_rent?=?new?Scanner(System.in).nextInt();
????????if?(is_rent?==?1)?{
????????????System.out.println("您可租車的類型及價目表:");
????????????Car?cars[]?=?{
????????????????????new?SmallCar("奧迪A4",?500,?4,?0),
????????????????????new?SmallCar("馬自達6",?400,?4,?0),
????????????????????new?Pick("皮卡雪6",?450,?4,?2),
????????????????????new?Bus("金龍",?800,?20,?0),
????????????????????new?Truck("松花江",?400,?0,?4),
????????????????????new?Truck("依維柯",?1000,?0,?20),
????????????};
????????????System.out.println("序號?汽車名稱?租金?容量");
????????????for?(int?i?=?0;?i?<?cars.length;?i++)?{
????????????????System.out.println(
????????????????????????i?+?1?+?"?"?+?cars[i].getName()?+?"?"?+?cars[i].getRent_money()?+?"元/天"?+?"?載人:"?+?cars[i].getCapacity_person()
????????????????????????????????+?"人?載貨:"?+?cars[i].getCapacity_goods()?+?"噸"
????????????????);
????????????}

????????????System.out.println("請輸入您要租賃汽車的數(shù)量");
????????????int?rent_count?=?0;?//?租車數(shù)量
????????????rent_count?=?new?Scanner(System.in).nextInt();
????????????Car?rent_cars[]?=?new?Car[rent_count];
????????????for?(int?i?=?0;?i?<?rent_count;?i++)?{
????????????????System.out.println("請輸入第"?+?(i?+?1)?+?"輛租賃的汽車序號");
????????????????int?number?=?0;?//?租車序號
????????????????number?=?new?Scanner(System.in).nextInt();
????????????????rent_cars[i]?=?cars[number?-?1];
????????????}

????????????int?rent_days?=?0;?//?租車天數(shù)
????????????System.out.println("請輸入您要租賃的天數(shù)");
????????????rent_days?=?new?Scanner(System.in).nextInt();

????????????int?person_count?=?0;?//?總載人數(shù)
????????????int?goods_count?=?0;??//?總載貨數(shù)
????????????int?rent_money_a_day?=?0;?//?租所選擇的所有車每天的租金

????????????System.out.println("您的賬單:");
????????????System.out.println("*****可載人的車有:");
????????????for?(int?i?=?0;?i?<?rent_cars.length;?i++)?{
????????????????if?(!(rent_cars[i]?instanceof?Truck))?{
????????????????????System.out.print(rent_cars[i].getName()?+?"?");
????????????????}
????????????????person_count?+=?rent_cars[i].getCapacity_person();
????????????????goods_count?+=?rent_cars[i].getCapacity_goods();
????????????????rent_money_a_day?+=?rent_cars[i].getRent_money();
????????????}

????????????System.out.println("共載人:"?+?person_count?+?"人");

????????????System.out.println("*****可載貨的車有:");
????????????for?(int?i?=?0;?i?<?rent_cars.length;?i++)?{
????????????????if?((rent_cars[i]?instanceof?Truck)?||?(rent_cars[i]?instanceof?Pick))?{
????????????????????System.out.print(rent_cars[i].getName()?+?"?");
????????????????}
????????????}
????????????System.out.println("共載貨:"?+?goods_count?+?"噸貨");

????????????System.out.println("*****租車總價格:"?+?rent_money_a_day?*?rent_days?+?"元");
????????}?else?{
????????????System.out.println("退出噠噠租車系統(tǒng)");
????????}
????????System.exit(0);

????}
}

http://img1.sycdn.imooc.com/5fb255de0001fa8207741184.jpg

正在回答

1 回答

hjh,代碼借來看看,謝大佬!


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

舉報

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

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

進入課程

大佬交作業(yè)啦,不服來看。

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

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

幫助反饋 APP下載

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

公眾號

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