public static abstract class GeometricObject
{
private String lineColor;
public abstract double calcArea();
public void setLineColor(String lineColor)
{
this.lineColor = lineColor;
}
public String getLineColor()
{
return lineColor;
}
public abstract String toString();
}
public static class Rectangle extends GeometricObject
{
private double height;
private double width;
public double getHeight() {
return height;
}
public void setHeight(double height) {
this.height = height;
}
public double getWidth() {
return width;
}
public void setWidth(double width) {
this.width = width;
}
@Override
public double calcArea() {
return width* height;
}
@Override
public String toString() {
return String.format( "Rectangle with %f width and %f height is drawn",width, height);
}
}
public static class Circle extends GeometricObject
{
private double radius;
public double getRadius() {
return radius;
}
public void setRadius(double radius) {
this.radius = radius;
}
@Override
public double calcArea() {
return Math.PI* Math.pow(radius,2);
}
@Override
public String toString() {
return String.format("Circle with %f radius is drawn",radius);
}
}
Comments
Leave a comment