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

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

我覺得自己思維還是跟不上

沒有什么思路,老師,能不能給一份完整的代碼作為參考呀。

正在回答

7 回答

package?cc.candydoll.yun;
import?java.util.Scanner;
public?class?Initail?{
??
??
?/**
??*?做一個答答租車系統(tǒng),顯示車的種類供用戶選擇
??*?車的種類分為三種,載人、載貨、即可以載人又可以載貨
??*?顯示出用戶選擇的車名,同時顯示出用戶選擇的車名
??*?最后再計算總金額
??*?@param?args
??*/
??
?static?Scanner?in=new?Scanner(System.in);
?static?int?sl;//保存用戶租車的?
?static?int?n;
?static?int?count=0;//統(tǒng)計輸入序號的次數(shù)
?static?int?d;//獲取天數(shù)
?static?int?allMoney=0;//統(tǒng)計總金額
?static?int?allPeople=0;//統(tǒng)計總?cè)藬?shù)
?static?double?allGoods=0;//統(tǒng)計貨物重量
??
?public?static?void?main(String[]?args)?{
??System.out.println("請問是否進(jìn)入答答租車系統(tǒng):1是?2否");
??n=in.nextInt();//獲取用戶輸入的值來確認(rèn)是否進(jìn)入系統(tǒng)
??if(n==1){
???Car?cars[]={new?People(1,"奧迪A4",500,4),//多態(tài)引用多個類?用數(shù)組遍歷多個對象
????new?People(2,"馬自達(dá)6",400,4),
????new?Pika(3,"皮卡雪6",450,4,2),
????new?People(4,"金龍",800,20),
????new?Goods(5,"松花江",400,4),
????new?Goods(6,"依維柯",1000,20)};
???System.out.println("請輸入租車的數(shù)量:");
???sl=in.nextInt();//獲取用戶租車的數(shù)量
???int[]?xh=new?int[sl];//通過數(shù)組保存輸入的序號
???while(count<sl){
????System.out.println("請輸入第"+(count+1)+"輛車的序號:");
????int?x=in.nextInt();//輸入的序號
????xh[count]=x;//將序號存儲在數(shù)組中
????count++;//通過累加的形式,將序號一一存儲在數(shù)組中
????continue;
???}
???System.out.println("請輸入租車天數(shù):");
???d=in.nextInt();
???//此部分計算
???//計算人數(shù)
???for(int?i=0;i<cars.length;i++){//循環(huán)cars數(shù)組。
????for(int?j=0;j<sl;j++){//循環(huán)用戶想租車的序號
?????if(cars[i].no==xh[j]&&cars[i].people>0&&cars[i].good>0){//此處判定pika類型的車輛,計算結(jié)果
??????System.out.print(cars[i].name+"?");//獲取pika車輛的名稱
??????allGoods=allGoods+cars[i].good;//獲取pika類型車輛的貨物重量,進(jìn)行計算
??????allPeople=allPeople+cars[i].people;//獲取pika類型的人數(shù),進(jìn)行計算
??????allMoney=allMoney+cars[i].money;//獲取pika類型的租金,進(jìn)行計算
?????}
????}
???}
???System.out.println("***載人的車:");
???for(int?i=0;i<cars.length;i++){
????for(int?j=0;j<sl;j++){
?????if(cars[i].no==xh[j]&&cars[i].people>0){//此處判定載人類型的車輛,計算結(jié)果載人數(shù)
??????System.out.print(cars[i].name+"?");
???????
??????allPeople=allPeople+cars[i].people;
??????allMoney=allMoney+cars[i].money;
?????}
????}
???}
????System.out.println("總?cè)藬?shù):"+allPeople);
????System.out.println("***可載物的車有:");
????for(int?i=0;i<cars.length;i++){//此處判定載貨類型的車輛,計算結(jié)果載物重量
????for(int?j=0;j<sl;j++){
?????if(cars[i].no==xh[j]&&cars[i].good>0){
??????System.out.println("***載貨的車:");
??????System.out.print(cars[i].name+"?");
??????allGoods=allGoods+cars[i].good;
??????allMoney=allMoney+cars[i].money;
?????}
????}
???}?
???System.out.println("總載貨量:"+allGoods+"噸");
???System.out.println("總金額"+allMoney*d);
??}else{
???System.out.println("即將退出答答租車系統(tǒng)");
??}
?}
??
}


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

慕碼人2389635

請問,多態(tài)引用多個類,相關(guān)知識視頻有介紹嗎?
2016-09-28 回復(fù) 有任何疑惑可以回復(fù)我~

“多態(tài)引用多個類?用數(shù)組遍歷多個對象?!边@東西我們學(xué)過嗎?

0 回復(fù) 有任何疑惑可以回復(fù)我~
package?cc.candydoll.yun;
public?class?Pika?extends?Car?{
?public?Pika(int?no,String?name,?int?money,int?people,double?good)?{
??super(no,name,?money,people,good);
??//?TODO?Auto-generated?constructor?stub
??System.out.println(no+".?"+name+"?"+money+"元/天?"+people+"?"+good+"噸");
?}
}


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

慕碼人2389635

這個是寫的接口嗎?
2016-09-28 回復(fù) 有任何疑惑可以回復(fù)我~
package?cc.candydoll.yun;
public?class?People?extends?Car?{
?public?People(int?no,String?name,?int?money,int?people)?{
??super(no,name,?money,people);
??//?TODO?Auto-generated?constructor?stub
??System.out.println(no+".?"+name+"?"+money+"元/天?"+people+"人");
?}
}


0 回復(fù) 有任何疑惑可以回復(fù)我~
package?cc.candydoll.yun;
public?class?Goods?extends?Car?{
?double?good;
?public?Goods(int?no,String?name,?int?money,double?good)?{
??super(no,name,?money,good);
??//?TODO?Auto-generated?constructor?stub
??setGood(good);
??System.out.println(no+".?"+name+"?"+money+"元/天?"+"?"+good+"噸");
?}
}


0 回復(fù) 有任何疑惑可以回復(fù)我~
package?cc.candydoll.yun;
class?Car?{
?int?no;
?String?name;
?int?money;
?int?people;
?double?good;
?public?Car(int?no,String?name,int?money,double?good){
??this.no=no;
??this.name=name;
??this.money=money;
??this.good=good;
?}
?public?Car(int?no,String?name,int?money,int?people){
??this.no=no;
??this.name=name;
??this.money=money;
??this.people=people;
?}
?public?Car(int?no,String?name,int?money,int?people,double?good){
??this.no=no;
??this.name=name;
??this.money=money;
??this.people=people;
??this.good=good;
?}
?public?String?getName()?{
??return?name;
?}
?public?void?setName(String?name)?{
??this.name?=?name;
?}
?public?int?getMoney()?{
??return?money;
?}
?public?void?setMoney(int?money)?{
??this.money?=?money;
?}
?public?int?getNo()?{
??return?no;
?}
?public?void?setNo(int?no)?{
??this.no?=?no;
?}
?public?int?getPeople()?{
??return?people;
?}
?public?void?setPeople(int?people)?{
??this.people?=?people;
?}
?public?double?getGood()?{
??return?good;
?}
?public?void?setGood(double?good)?{
??this.good?=?good;
?}
??
}


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

買本書仔細(xì)復(fù)習(xí)下

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

舉報

0/150
提交
取消

我覺得自己思維還是跟不上

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

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

幫助反饋 APP下載

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

公眾號

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