自定义抽象平面图形类,内含抽象的面积和周长计算方法。定义继承抽象图形类的圆类
2个回答
展开全部
public abstract class Shape {
public abstract double getCircumference ();
public abstract double getSquare();
}
public class Circle extends Shape {
public double radius;
@Override
public double getCircumference() {
// TODO Auto-generated method stub
return 3.14 * 2 * radius;
}
@Override
public double getSquare() {
// TODO Auto-generated method stub
return 3.14 * radius * radius;
}
}
public abstract double getCircumference ();
public abstract double getSquare();
}
public class Circle extends Shape {
public double radius;
@Override
public double getCircumference() {
// TODO Auto-generated method stub
return 3.14 * 2 * radius;
}
@Override
public double getSquare() {
// TODO Auto-generated method stub
return 3.14 * radius * radius;
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询