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

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

就是關(guān)于JAVA入門第二季最后那個(gè)綜合練習(xí)題,請(qǐng)問(wèn)最后怎樣可以實(shí)現(xiàn)對(duì)已經(jīng)選擇了的車輛name的輸出?以下是自己寫的程序

(父類)
package?imooc1;

public?class?car?{
????public??String?number;
????public??String?name;
????public??int????people;
????public??int????weight;
????public??int????price;
???
/*生產(chǎn)setter和getter方法*/
	public?String?getNumber()?{
		return?number;
	}
	public?void?setNumber(String?number)?{
		this.number?=?number;
	}
	public?String?getName()?{
		return?name;
	}
	public?void?setName(String?name)?{
		this.name?=?name;
	}
	public?int?getPeople()?{
		return?people;
	}
	public?void?setPeople(int?people)?{
		this.people?=?people;
	}
	public?int?getWeight()?{
		return?weight;
	}
	public?void?setWeight(int?weight)?{
		this.weight?=?weight;
	}
	public?int?getPrice()?{
		return?price;
	}
	public?void?setPrice(int?price)?{
		this.price?=?price;
	}
	
????
}

(子類)
package?imooc1;

import?java.util.Scanner;

public?class?rental?extends?car?{
	public?static?void?main(String[]?args){
		System.out.println("歡迎使用達(dá)達(dá)租車系統(tǒng):");
		System.out.println("您是否要租車:1是0否");
/*創(chuàng)建Scanner對(duì)象,用戶輸入數(shù)據(jù)*/
		Scanner?input=new?Scanner(System.in);
/*獲取用戶輸入的信息*/				
		int?wh=input.nextInt();
		if(wh==1){
/*調(diào)用并輸出6個(gè)方法可供選擇,并輸出6個(gè)對(duì)象的全部信息*/
		rental?car1=new?rental();
		?car1.aud();
		rental?car2=new?rental();?
		?car2.maz();
		rental?car3=new?rental();
		?car3.pick();
		rental?car4=new?rental();
		?car4.jinl();
		rental?car5=new?rental();?
		?car5.sonha();
		?rental?car6=new?rental();
		car6.yiwek();
	System.out.println("請(qǐng)輸入您要租的車的數(shù)量:");	
		}
/*輸出客戶選擇的汽車數(shù)量*/		
		Scanner?input1=new?Scanner(System.in);
		/*獲取用戶輸入的信息*/				
		int?wc=input1.nextInt();
		double?count=0;
		double?wei=0;
		int?peo=0;
		//String?har;
	for(int?i=1;i<=wc;i++){
			System.out.println("請(qǐng)輸入第"+i+"輛車的序號(hào):");
			Scanner?input2=new?Scanner(System.in);
			int?w=input2.nextInt();//輸入選擇的車序號(hào)
	switch(w){
	?????
		case?1:count+=500;peo+=4;break;//奧迪A4
		case?2:count+=400;peo+=4;break;//馬自達(dá)6
		case?3:count+=450;wei+=2;break;//皮卡雪6
		case?4:count+=800;peo+=20;break;//金龍
		case?5:count+=400;wei+=4;break;//松花江
		case?6:	count+=1000;wei+=20;//依維柯
		
		}
		}		
		System.out.println("請(qǐng)輸入租車天數(shù):");
		Scanner?input2=new?Scanner(System.in);
		int?w=input2.nextInt();//輸入租用天數(shù)
		?count=?count*wc;//所有租車費(fèi)用
		System.out.println("您的賬單:");
		System.out.println("可載人的車有:");
		System.out.println("總載人數(shù):"+peo);
		System.out.println("可載貨的車有:");
		System.out.println("總載貨:"+wei+"噸");
		System.out.println("租車總費(fèi)用為"+count);
	}

	
/*創(chuàng)建6個(gè)車型對(duì)象方法*/
	public?void?aud(){
	????this.number="1";?????
		this.price=500;
		this.name="奧迪A4";
		this.people=4;
	System.out.println("序號(hào)"+number+"???車型"+name+"???價(jià)格"+price+"元/天???????載物量"+people+"人");	
}
	public?void?maz(){
		this.number="2";?????
		this.price=400;
		this.name="馬自達(dá)6";
		this.people=4;
	System.out.println("序號(hào)"+number+"???車型"+name+"???價(jià)格"+price+"元/天???????載物量"+people+"人");
	}
	public?void?pick(){
		this.number="3";?????
		this.price=450;
		this.name="皮卡雪6";
		this.people=4;
		this.weight=6;
	System.out.println("序號(hào)"+number+"???車型"+name+"????價(jià)格"+price+"元/天????????載物量"+people+"人?/"+weight+"噸");
	}
	public?void?jinl(){
		this.number="4";?????
		this.price=800;
		this.name="金龍";
		this.people=20;
	System.out.println("序號(hào)"+number+"???車型"+name+"???價(jià)格"+price+"元/天???????載物量"+people+"人");
	}
	public?void?sonha(){
		this.number="5";?????
		this.price=400;
		this.name="松花江";
		this.weight=4;
	System.out.println("序號(hào)"+number+"???車型"+name+"???價(jià)格"+price+"元/天???????載物量"+weight+"噸");
	}
	public?void?yiwek(){
		this.number="6";?????
		this.price=1000;
		this.name="依維柯";
		this.weight=20;
	System.out.println("序號(hào)"+number+"???車型"+name+"???價(jià)格"+price+"元/天???????載物量"+weight+"噸");
	}
}

怎樣在switch語(yǔ)句中收集已選擇了的汽車車型名字?當(dāng)局者迷,求老師指點(diǎn)。。。。。。。Iam waiting?

正在回答

1 回答

你可以定義一個(gè)字符串,然后在switch中將車的名字拼接在這個(gè)字符串中

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

感覺(jué)不到 提問(wèn)者

非常感謝!
2014-11-22 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

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

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

進(jìn)入課程

就是關(guān)于JAVA入門第二季最后那個(gè)綜合練習(xí)題,請(qǐng)問(wèn)最后怎樣可以實(shí)現(xiàn)對(duì)已經(jīng)選擇了的車輛name的輸出?以下是自己寫的程序

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

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

幫助反饋 APP下載

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

公眾號(hào)

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