想問下這個(gè)哪里錯(cuò)了
由于是英語學(xué)渣。大家湊合看拼英。
//以下是父類
package com.imoocc;
public abstract class tuxing {
?public double chang=5;
?public double kuang=4;
?public double banjing=10;
public abstract void zhouchang();
public abstract void mianji();
}
//以下是子類
package com.imoocc;
public abstract class juxing extends tuxing {
?@Override
?public void zhouchang() {
??// TODO Auto-generated method stub
??
??double zhouchang=(chang+kuang)*2;
?System.out.println("矩形的周長(zhǎng)是:"+zhouchang);
?}
?@Override
?public void mianji() {
??// TODO Auto-generated method stub
???? double mianji=chang*kuang;
??? System.out.println("矩形的面積是:"+mianji);
?}
}
//以下是子類
package com.imoocc;
public abstract class yuanxing extends tuxing {
?@Override
?public void zhouchang() {
??// TODO Auto-generated method stub
?? double zhouchang=2*3.14*banjing;
?System.out.println("圓形的周長(zhǎng)是:"+zhouchang);
?}
?@Override
?public void mianji() {
??// TODO Auto-generated method stub
?? double mianji=3.14*(banjing*banjing);
?System.out.println("圓形的面積是:"+mianji);
?}
}
//以下是測(cè)試類
package com.imoocc;
public class ceshi {
?public static void main(String[] args) {
??// TODO Auto-generated method stub
???? tuxing a=new juxiang ();
?}
}
寫到測(cè)試類的時(shí)候這句指定對(duì)象的時(shí)候eclipse報(bào)錯(cuò)了,報(bào)的是juxiang cannot be resolved to a type
想問一下哪里是有錯(cuò)誤的,找了好久沒找出來,謝謝
2018-05-12
總結(jié)一下你有兩個(gè)錯(cuò):1、juxing和yuanxing不用加abstract,抽象類是無法實(shí)例化的。
2、你juxing在ceshi類中拼錯(cuò)了。
2018-05-12
并把ceshi類中的juxiang改為juxing
2018-05-12
你把juxing和yuanxing定義時(shí)候的abstract去掉,實(shí)現(xiàn)的時(shí)候不用abstract