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

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

求大神點(diǎn)評(píng)我做的這個(gè)項(xiàng)目(第一次做項(xiàng)目)。

父類(lèi)

package?com.zuche;

public??class?CarProperty?{
	/*public?String?carP1;//車(chē)輛名稱(chēng)
	public??String?carP2;?//車(chē)輛類(lèi)型
	?public?int?carP3;//載客量
?????public??int?carP4;//載貨量
?????public?int?carP5;?//租金每天
??????*/
	public?void?show(String?carP1,String?carP2,int?carP3,int?carP4,int?carP5)?{
		?System.out.println("?????"+carP1+"????????????????"+carP2+"???????????"+carP3+"?"
		?		+?"????"+carP4+"????"+carP5);
	}

}

子類(lèi)

package?com.zuche;

public?class?HuoChe?extends?CarProperty{
??????????
}
package?com.zuche;

public?class?KeChe?extends?CarProperty?{

}
package?com.zuche;

public?class?PiKa?extends?CarProperty?{

}

測(cè)試

package?com.zuche;
import?java.util.*;
public?class?Initial?{

	public?static?void?main(String[]?args)?{
		//?TODO?Auto-generated?method?stub
		CarProperty?huo1=new?HuoChe();
		CarProperty?huo2=new?HuoChe();
		??CarProperty?ke1=new?KeChe();
		??CarProperty?ke2=new?KeChe();
		?????CarProperty?pi1=new?PiKa();
		?????CarProperty?pi2=new?PiKa();
		????
		?????int??sum=0;
		int?i3=0;
????System.out.println("請(qǐng)您選擇是否租車(chē)?");
????System.out.println("1,是????2,否");
????Scanner?input1=new?Scanner(System.in);
??????int?i1=input1.nextInt();
????if(i1==1)?{
????	System.out.println("車(chē)輛名稱(chēng)???車(chē)輛類(lèi)型???載客量/人???載貨量/噸???租金/每天");
????	huo1.show("1,奧迪",?"貨車(chē)",?2,?3,?100);
????	huo2.show("2,奧拓",?"貨車(chē)",?2,?2,?80);
????	ke1.show("3,寶馬",?"客車(chē)",?4,?0,?150);
????	ke2.show("4,一汽",?"客車(chē)",?4,?0,?100);
????	pi1.show("5,五菱",?"兩用",?8,?2,?80);
????	pi2.show("6,奔馬",?"兩用",?2,?3,?60);
????	System.out.println("請(qǐng)您選擇租車(chē)數(shù)量:");
????	Scanner?input2=new?Scanner(System.in);
????	??int?i2=input2.nextInt();
????	??for(int?i=1;i<i2+1;i++)?{
????		??System.out.println("請(qǐng)輸入您要租用的第"+i+"輛車(chē)的編號(hào)");
????		??Scanner?input3=new?Scanner(System.in);
????		????i3=input3.nextInt();
????		??if(i3<0||i3>6)?{
????			??System.out.println("請(qǐng)檢查您輸入的編號(hào)是否正確!");
????			??break;
????		??}else?{
????		??if(i3==1)?{
????			sum=sum+100;
????		??}
????		??if(i3==2)?{
????			??sum=sum+80;
????		??}
????		??if(i3==3)?{
????			??sum=sum+150;
????			??}if(i3==4)?{
????				??sum=sum+100;
????			??}
????			??if(i3==5)?{
????				??sum=sum+80;
????			??}if(i3==6)?{
????				??sum=sum+60;
????			??}}
????			?
????	??}if(i3>0&&i3<7)?{
????	???System.out.println("請(qǐng)輸入租用的天數(shù)");
????	??Scanner?input4=new?Scanner(System.in);
????	??int?sum1=input4.nextInt();
????	??sum=sum*sum1;
????	??System.out.println("總共租車(chē):"+i2+"輛,租用:"+sum1+"天,共需:"+sum+"元人民幣。");
????	??}else?{
????		??System.out.println("請(qǐng)重新操作!");
????	??}?}else?{
????	System.out.println("感謝使用該系統(tǒng)!");
????}
????
????
	}

}

我自己感覺(jué)很簡(jiǎn)單粗暴。

正在回答

3 回答

這個(gè)項(xiàng)目代碼量不大,父類(lèi)可以寫(xiě)成虛擬類(lèi),子類(lèi)重寫(xiě)父類(lèi)輸出函數(shù),就可以省去在主函數(shù)里分開(kāi)計(jì)算的諸多else if語(yǔ)句

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

long_l 提問(wèn)者

非常感謝!
2017-07-18 回復(fù) 有任何疑惑可以回復(fù)我~
#2

qq_慕姐9261892 回復(fù) long_l 提問(wèn)者

int sum=0; int i3=0; System.out.println("請(qǐng)您選擇是否租車(chē)?"); System.out.println("1,是 2,否"); Scanner input1=new Scanner(System.in); int i1=input1.nextInt(); if(i1==1)這里段代碼是什么意思
2019-03-23 回復(fù) 有任何疑惑可以回復(fù)我~

寫(xiě)的真好,但是如果有總載人,總載貨,以及輸出載人的有,載貨的有,該怎么往這個(gè)里面加呢??

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

感覺(jué)你寫(xiě)的非常不錯(cuò),我寫(xiě)的代碼沒(méi)有用到繼承和抽象類(lèi)非常繁瑣。

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

long_l 提問(wèn)者

謝謝鼓勵(lì),一起加油
2017-07-25 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

求大神點(diǎn)評(píng)我做的這個(gè)項(xiàng)目(第一次做項(xiàng)目)。

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

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

幫助反饋 APP下載

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

公眾號(hào)

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