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

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

就是關(guān)于JAVA入門第二季最后那個綜合練習題,請問最后怎樣可以實現(xiàn)對已經(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("歡迎使用達達租車系統(tǒng):");
		System.out.println("您是否要租車:1是0否");
/*創(chuàng)建Scanner對象,用戶輸入數(shù)據(jù)*/
		Scanner?input=new?Scanner(System.in);
/*獲取用戶輸入的信息*/				
		int?wh=input.nextInt();
		if(wh==1){
/*調(diào)用并輸出6個方法可供選擇,并輸出6個對象的全部信息*/
		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("請輸入您要租的車的數(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("請輸入第"+i+"輛車的序號:");
			Scanner?input2=new?Scanner(System.in);
			int?w=input2.nextInt();//輸入選擇的車序號
	switch(w){
	?????
		case?1:count+=500;peo+=4;break;//奧迪A4
		case?2:count+=400;peo+=4;break;//馬自達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("請輸入租車天數(shù):");
		Scanner?input2=new?Scanner(System.in);
		int?w=input2.nextInt();//輸入租用天數(shù)
		?count=?count*wc;//所有租車費用
		System.out.println("您的賬單:");
		System.out.println("可載人的車有:");
		System.out.println("總載人數(shù):"+peo);
		System.out.println("可載貨的車有:");
		System.out.println("總載貨:"+wei+"噸");
		System.out.println("租車總費用為"+count);
	}

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

怎樣在switch語句中收集已選擇了的汽車車型名字?當局者迷,求老師指點。。。。。。。Iam waiting?

正在回答

1 回答

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

0 回復 有任何疑惑可以回復我~
#1

感覺不到 提問者

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

舉報

0/150
提交
取消
Java入門第二季 升級版
  • 參與學習       531213    人
  • 解答問題       6327    個

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

進入課程

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

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

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

幫助反饋 APP下載

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

公眾號

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