亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

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

Cannot instantiate the type Keche

?答答租車 ?問題

package?ZuChe;
//虛擬?汽車類
public?abstract?class?Qiche?{
??int?rent;//價格
?
??String?name;//汽車名字
??public?abstract?void?shuChu();//虛擬方法體?shuChu
??
??public?Qiche(int?rent?,String?name){
	??this.rent?=rent?;//有參構造方法??初始化成員變量	?
	??this.name=name;
??}
??//定義?的getRent?方法
	public?int?getRent(){
		return?rent;
	}
}


package ZuChe;


public abstract class Keche extends Qiche {

? ? ?int num;

public void shuChu(){

System.out.println(name+" "+rent+"/天"+"載人:"+num);

}

public Keche(int rent ,String name, int num){

super(rent,name);

this.num=num;

}

}



package ZuChe;


public abstract class Khche extends Qiche {

?int ton;

?int num;

public Khche(int rent, String name,int num,int ton) {

super(rent,name);

this.ton=ton;

this.num=num;

// TODO Auto-generated constructor stub

}

public void shuChu() {

// TODO Auto-generated method stub

System.out.println(name+" "+rent+"/天"+" ?"+"載人:"+num+"載貨"+ton);

}

}



package ZuChe;

import java.util.Scanner;

public class Test {


public static void main(String[] args) {

// TODO Auto-generated method stub

? System.out.println("歡迎使用答答租車系統:");

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

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

? ?int t = input.nextInt();

? ?Qiche[] qiche={

? new Keche(500,"奧迪A4",4),

? new Keche(400,"馬自達6",4),

? new Khche(450,"皮卡雪6",4,2),

? new Keche(800,"金龍",20),

? new Huoche(400,"松花江",4),

? new Huoche(1000,"依維柯",20)

? ?

? ?} ;

}


}



在Qiche[] qiche ?= {

new Keche ?紅線 ?Cannot instantiate the type Keche

new Khche ?紅線Cannot instantiate the type Keche

}

正在回答

1 回答

Qiche qiche[5];?

qiche[0]=new Keche(500,"奧迪A4",4)

qiche[1]=new Keche(400,"馬自達6",4)

......

這樣試試 我也就猜猜 ?

希望對你有幫助

如果沒對 ? 等你解決問題的時候 ?麻煩 告訴我一聲 ?我也好奇

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

舉報

0/150
提交
取消

Cannot instantiate the type Keche

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號