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

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

作業(yè)代碼,傻瓜版

學(xué)得時間太短了,就只會用一點(diǎn)簡單方法,用了抽象的多態(tài),if,for,switch,import 。感覺思路還是比較清楚。先父類 再子類最后是操作Initail.(先寫了分開的 后面合起來的時候出了點(diǎn)問題 加了static 就好了(public class Jl extends Auto 改成public static class Jl extends Auto?))

package 綜合作業(yè)合;

import java.util.*;

public abstract class Auto {

? ?public ?String Name;

public float Price;

public int Nm;

public int Zkl;

public int Zhl;

public abstract void Run();

?//

public static class Ada4 extends Auto {

public String Name="奧迪A4";

public float Price=500;

public int Nm=1;

public int Zkl=4;

? ? ? ? public ?void Run() {

? ? ? ? ? ?System.out.println(Nm+" ? ? "+Name+" ? "+Price+"元/天"+" ?"+Zkl+"人");

}

? ? ? ? ?}

//

public static class Jl extends Auto {

public String Name="金龍";

public float Price=800;

public int Nm=4;

public int Zkl=20;

? ?public void Run() {

System.out.println(Nm+" ? ? "+Name+" ? ? ? ? "+Price+"元/天"+" ?"+Zkl+"人");

? ? ? ? }

? ? ? ? ? ?}

? ?//

public static class Mzd6 extends Auto {

public String Name="馬自達(dá)6";

public float Price=400;

public int Nm=2;

public int Zkl=4;

? ?public void Run() {

System.out.println(Nm+" ? ? "+Name+" ?"+Price+"元/天"+" ?"+Zkl+"人");

}

? ? ? ?}

//

public static class Pkx extends Auto {

public String Name="皮卡雪6";

public float Price=450;

public int Nm=3;

public int Zkl=4;

public int Zhl=2;

public void Run() {

System.out.println(Nm+" ? ? "+Name+" ?"+Price+"元/天"+" ? "+Zkl+"人"+Zhl+"噸");

}

}

//

public static class Shj extends Auto {

public String Name="松花江";

public float Price=400;

public int Nm=5;

public int Zhl=4;

public void Run() {

System.out.println(Nm+" ? ? "+Name+" ? ? "+Price+"元/天"+" ? "+Zhl+"噸");

}?

}

//

public static class Ywh extends Auto {

public String name="依維河";

public float price=1000;

public int Nm=6;

? ? ? ? public int Zhl=20;

public void Run() {

System.out.println(Nm+" ? ? "+name+" ? ? "+price+"元/天"+" ?"+Zhl+"噸");

}


}


public static void main(String[] args) {

System.out.println("您是否租車? ?1是 0否");

Scanner input = new Scanner(System.in);

? int r = input.nextInt(); ?

? if(r==1){

System.out.println("您可租車的類型及其價目表:");

System.out.println("序號"+" ?"+"汽車名稱"+" ? ? ?"+"租金"+" ? ? ? ? "+"容量");

Auto i1=new Ada4();

i1.Run();

Auto i2=new Mzd6();

i2.Run();

Auto i3=new Pkx();

i3.Run();

Auto i4=new Jl();

i4.Run();

Auto i5=new Shj();

i5.Run();

Auto i6=new Ywh();

i6.Run();

System.out.println("請輸入您要租車的數(shù)量:");

Scanner input1 = new Scanner(System.in);

? int r1 = input1.nextInt();?

? float ?num=0;

? int a1=0,a2=0,a3=0,a4=0,a5=0,a6=0;

? ? for(int n=1;n<=r1;n++){

? ? System.out.println("請輸入第"+n+"輛車的序號");

? Scanner input2 = new Scanner(System.in);

? ? int z = input2.nextInt();?

? ? switch(z){

? ? case 1:

? ? num=num+500;

? ? a1++;

? ? break;

? ? case 2:

? ? num=num+400;

? ?a2++;

? ? break;

? ? case 3:

? ? num=num+450;

? ? a3++;

? ? break;

? ? case 4:

? ? num=num+800;

? ? a4++;

? ? break;

? ? case 5:

? ? num=num+400;

? ? a5++;

? ? break;

? ? case 6:

? ? num=num+1000;

? ? a6++;

? ? break; ??

? ? }

? ? ? ? ?}

? ? ? ? ? ? ?System.out.println("請輸入租車的天數(shù):");

? ? ? ? ? ? Scanner input3 = new Scanner(System.in);

? ? ? ? ? ? ? int x = input3.nextInt();?

? ? ?int sumpeople=a1*4+a2*4+a3*4+a4*20+a5*0+a6*0;?

? ? ?int sumzaihuo=a3*2+a5*4+a6*20;

? ? ?float sumzongjia=num*x;

? ? ? ? ? ? ? System.out.println("您的賬單:");

? ? ? ? ? ? ??

? ? ? ? ? ? ? System.out.println("***可載人的車有:");

? ? ? ? ? ? ? if(a1>0){System.out.print("奧迪A4,");}

? ? ? ? ? ? ? if(a2>0){System.out.print("馬自達(dá)6,");}

? ? ? ? ? ? ? if(a3>0){System.out.print("皮卡雪6,");}

? ? ? ? ? ? ? if(a4>0){System.out.print("金龍,");}

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

? ? ? ? ? ? ? System.out.println("***載貨的車有:");

? ? ? ? ? ? ? if(a3>0){System.out.print("皮卡雪6,");}

? ? ? ? ? ? ? if(a5>0){System.out.print("松花江,");}

? ? ? ? ? ? ? if(a6>0){System.out.print("依維河,");}

? ? ? ? ? ? ? System.out.println("共載貨:"+sumzaihuo);

? ? ? ? ? ? ? System.out.println("租車總價:"+sumzongjia);

}


}


}


正在回答

1 回答

為什么要加static?新手同問。

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

qq_時光老佡_04298173 提問者

我也不懂,求解。。
2016-12-02 回復(fù) 有任何疑惑可以回復(fù)我~
#2

qq_沒有開始_0 回復(fù) qq_時光老佡_04298173 提問者

static修飾的變量是同一類中所有對象共有的,而不用static修飾的變量針對不同對象是各自獨(dú)立的。比如,我在a對象中創(chuàng)建了成員變量age,把它賦值為10,在b對象中創(chuàng)建了成員變量age,把它賦值為15,此時輸出a對象中的age,結(jié)果還是,10。因?yàn)閷τ诿總€對象,變量都是獨(dú)立的,但是假如我用了static,就會輸出15。因?yàn)槿珕T共有了。
2016-12-04 回復(fù) 有任何疑惑可以回復(fù)我~

舉報

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

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

進(jìn)入課程

作業(yè)代碼,傻瓜版

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

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

幫助反饋 APP下載

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

公眾號

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