问答详情
源自:10-3 Java 中的抽象类

遇到了无法攻克的难题,为什么我的测试类有错啊?请大神帮帮忙!感激不尽

package package2;


public abstract class Shape {

public abstract void zhouchang();

public abstract void mianji();

}

--------------------------------------------------------------------

package package2;


public class Rectangle extends Shape{

@Override

public void zhouchang() {

// TODO Auto-generated method stub

double length=10;

double wide=10;

double perimeter=(length+wide)*2;

}


@Override

public void mianji() {

// TODO Auto-generated method stub

double length=10;

double wide=10;

double area=length*wide;

}


}

----------------------------------------------

package package2;


public class Circle extends Shape{

@Override

public void zhouchang() {

// TODO Auto-generated method stub

double radius=5;

    final double P=3.14;

double perimeter=2*P*radius;

}


@Override

public void mianji() {

// TODO Auto-generated method stub

double radius=5;

    final double P=3.14;

double area=P*radius*radius;

}


}

-------------------------------------

package package2;


public class test {

   Shape Rec=new Rectangle();

   Rec.zhouchang();

   Rec.mianji();

   Shape Cir=new Circle();

   Cir.zhouchang();

   Cir.mianji();



}


提问者:小可爱z 2018-10-18 11:51

个回答

  • 慕雪3349881
    2018-10-18 16:33:23
    已采纳

    你方法里没写输出语句

  • 慕码人7502429
    2018-10-23 14:39:23

    你没有主方法,子类里面没有输出语句