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

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

如何正確傳值呢 求指點 謝謝啦~~

//父類

package ThirdEx;

public abstract class One{
?? ?
?? ?public static int number;
?? ?public static int carMoney;
?? ?public int no;
?? ?public String carName;
?? ?public static int weight;

?? ?public void Aodi() {
?? ??? ?// TODO Auto-generated method stub
?? ??? ?System.out.println(no+"."+"??? "+carName+"??? "+carMoney+"/day"+"??? "+"can carry person:"+number);
?? ?}
?? ?public void Mazida() {
?? ??? ?// TODO Auto-generated method stub
?? ??? ?System.out.println(no+"."+"??? "+carName+"??? "+carMoney+"/day"+"??? "+"can carry person:"+number);
?? ?}
?? ?public void PiKaxue() {
?? ??? ?// TODO Auto-generated method stub
?? ??? ?System.out.println(no+"."+"??? "+carName+"??? "+carMoney+"/day"+"??? "+"can carry person:"+number+"??? "+"can carry weight:"+weight+"t");
?? ?}
?? ?public void JinLong() {
?? ??? ?// TODO Auto-generated method stub
?? ??? ?System.out.println(no+"."+"??? "+carName+"??? "+carMoney+"/day"+"??? "+"can carry person:"+number);
?? ?}
?? ?public void SongHuaJiang() {
?? ??? ?// TODO Auto-generated method stub
?? ??? ?System.out.println(no+"."+"??? "+carName+"??? "+carMoney+"/day"+"??? "+"can carry weight:"+weight+"t");
?? ?}
?? ?public void YiWeiHe() {
?? ??? ?// TODO Auto-generated method stub
?? ??? ?System.out.println(no+"."+"??? "+carName+"??? "+carMoney+"/day"+"??? "+"can carry weight:"+weight+"t");
?? ?}
}


//Aodi類

package ThirdEx;

public class Aodi extends One {
?? ?public Aodi(){
???????? no = 1;
?? ??? ?carName = "Aodi";
?? ??? ?carMoney = 500;
?? ??? ?number = 4;
?? ?}
}

//Mazida類

package ThirdEx;

public class Mazida extends One {
?? ?public Mazida(){
?? ???? no=2;
?? ??? ?carName="Mazida";
?? ??? ?carMoney=400;
?? ??? ?number=4;
?? ?}
}

//PiKaxue類

package ThirdEx;

public class PiKaxue extends One {
?? ?public PiKaxue(){
?? ??? ?no=3;
?? ??? ?carName="PiKaxue";
?? ??? ?carMoney=450;
?? ??? ?number=4;
?? ??? ?weight=2;
?? ?}
}

還有其他車的類都一樣的寫法 就不貼上來了

//測試類

package ThirdEx;

import java.util.Scanner;

public class Initial {

?? ?private static int b;

?? ?/**
?? ? * @param args
?? ? */
?? ?public static void main(String[] args) {
?? ??? ?// TODO Auto-generated method stub
?? ??? ?System.out.println("Welcome to DADA Rent Car!If you want to rent a car?" );
?? ??? ?System.out.println("1.Yes??? 0.No");
?? ??? ?
?? ??? ?Scanner input =new Scanner(System.in);
?? ??? ?int a=input.nextInt();
?? ??? ?if(a==0){
?? ??? ??? ?System.out.println("Thank you!Good bye!");
?? ??? ?}else if(a==1){
?? ??? ??? ?System.out.println("You can use these cars:");
?? ??? ??? ?
?? ??? ??? ?Aodi carA=new Aodi();
?? ??? ??? ?carA.Aodi();
?? ??? ??? ?
?? ??? ??? ?Mazida carM=new Mazida();
?? ??? ??? ?carM.Mazida();
?? ??? ??? ?
?? ??? ??? ?PiKaxue carP=new PiKaxue();
?? ??? ??? ?carP.PiKaxue();
?? ??? ??? ?
?? ??? ??? ?JinLong carJ=new JinLong();
?? ??? ??? ?carJ.JinLong();
?? ??? ??? ?
?? ??? ??? ?SongHuaJiang carS=new SongHuaJiang();
?? ??? ??? ?carS.SongHuaJiang();
?? ??? ??? ?
?? ??? ??? ?YiWeiHe carY=new YiWeiHe();
?? ??? ??? ?carY.YiWeiHe();
?? ??? ??? ?
?? ??? ??? ?System.out.println("How much cars do you want?");
?? ??? ??? ?
?? ??? ??? ?Scanner input11=new Scanner(System.in);
?? ??? ??? ?b = input11.nextInt();
?? ??? ??? ?int sum=0;
?? ??? ??? ?int people=0;
?? ??? ??? ?int weight=0;
?? ??? ??? ?for(int i=1;i<=b;i++){
?? ??? ??? ??? ?
?? ??? ??? ?System.out.println("Please enter the "+i+" car's No.");
?? ??? ??? ?Scanner inputi=new Scanner(System.in);
?? ??? ??? ?int id=input.nextInt();
?? ?
?? ??? ??? ?if(id==1){
?? ??? ??? ??? ? sum=sum+Aodi.carMoney;
?? ??? ??? ??? ? people=people+Aodi.number;
?? ??? ??? ? }
?? ??? ??? ? if(id==2){
?? ??? ??? ??? ? sum=sum+Mazida.carMoney;
?? ??? ??? ??? ? people=people+Mazida.number;
?? ??? ??? ? }
?? ??? ??? ? if(id==3){
?? ??? ??? ??? ? sum=sum+PiKaxue.carMoney;
?? ??? ??? ??? ? people=people+PiKaxue.number;
?? ??? ??? ??? ? weight=weight+PiKaxue.weight;
?? ??? ??? ? }
?? ??? ??? ? if(id==4){?? ??? ??? ??? ?
?? ??? ??? ??? ? sum=sum+JinLong.carMoney;
?? ??? ??? ??? ? people=people+JinLong.number;
?? ??? ??? ? }
?? ??? ??? ? if(id==5){?? ??? ??? ??? ?
?? ??? ??? ??? ? sum=sum+SongHuaJiang.carMoney;
?? ??? ??? ??? ? weight=weight+SongHuaJiang.weight;;
?? ??? ??? ? }
?? ??? ??? ? if(id==6){?? ??? ??? ??? ?
?? ??? ??? ??? ? sum=sum+YiWeiHe.carMoney;
?? ??? ??? ??? ? weight=weight+YiWeiHe.weight;
?? ??? ??? ? }? ??? ????
?? ??? ??? ?}
?? ??? ??? ?? ??? ??? ?
?? ??? ??? ?
?? ??? ??? ?System.out.println("Plaese enter the days do you want to rent?");
?? ??? ??? ?Scanner input12=new Scanner(System.in);
?? ??? ??? ?int c1=input12.nextInt();
?? ??? ??? ?
?? ??? ??? ?System.out.println("Your pill is:");
?? ??? ??? ?System.out.println("can carry "+ people +"people");
?? ??? ??? ?System.out.println("can carry "+ weight +"weight");
?? ??? ??? ?int sumTotil = sum*c1;
?? ??? ??? ?System.out.println("All money:"+sumTotil);
?? ??? ?}????
?? ?}
}


我測試的結(jié)果就是錯的 http://img1.sycdn.imooc.com//599e3ed600018f0007370558.jpg

為什么傳人數(shù)、車錢的值都是似乎是地址值而不是我賦的值呢 求指點

正在回答

2 回答

cars 用 many。。。

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

你最后的輸出輸出的是啥!

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

qq_年輕老男人_0

算法不對
2017-08-25 回復 有任何疑惑可以回復我~
#2

看看別人家的孩子 提問者 回復 qq_年輕老男人_0

哪兒的算法不對啊 求指出 現(xiàn)在是懵的了 hhhh....
2017-08-25 回復 有任何疑惑可以回復我~

舉報

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

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

進入課程

如何正確傳值呢 求指點 謝謝啦~~

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

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

幫助反饋 APP下載

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

公眾號

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