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();
}
你方法里没写输出语句
你没有主方法,子类里面没有输出语句