Design an abstract class called shape This class contains a
\"Design an abstract class called shape. This class contains a single constructor that accepts a numeric value that is used to calculate various values, one of which is area. Include in the class abstract mutator method called findArea that can be defined to find the are of various shapes. Also provide a concrete accessor method to return the area.
Design 2 concrete classes Circle and Square that inherits the class Shape. Each of these classes finds the respective area; I.E. are of circle and area of square.
You are responsible for providing any relevant variables
You are not required to write a test class\"
Please help
Solution
Shape.java
package abstractdemo;
public abstract class Shape {
private double findArea;
/**
* @return the findArea
*/
public abstract double getFindArea(double diameter);
/**
* @param findArea the findArea to set
*/
public void setFindArea(double findArea) {
this.findArea = findArea;
}
}
Circle.java
package abstractdemo;
public class Circle extends Shape{
private static final double PI = Math.PI; // constant
@Override
public double getFindArea(double diameter) {
double radius = diameter / 2.0;
return PI * radius * radius;
}
}
Why constructor for abstract class there is no use for can you eleborate it ?

