public abstract class Shape {
/**
* The default size used in constructing a shape.
*/
protected static final double DEFAULT_SIZE = (double) 1.0;
protected static final String DEFAULT_NAME = "Unknown";
private String shapeName;
/**
* Construct a generic instance of unknown shape type.
*/
public Shape(){
this.shapeName = DEFAULT_NAME;
}
/**
* Construct a Shape whose type is specified in
* the argument.
* @param name the name of this kind of shape
*/
public Shape( String name ){
setShapeName( name );
}
/**
* Reset the shape name for this Shape.
* @param name the name of this kind of shape
*/
protected void setShapeName( String name ) {
if ( name.trim().length() == 0 )
shapeName = DEFAULT_NAME;
else
shapeName = new String( name );
}
/**
* Get the name of this kind of shape.
* @return the name of this shape
*/
public String getShapeName() {
return shapeName;
}
/**
* Get the surface area of this Shape.
* @return the surface area of this Shape
*/
public abstract double getSurfaceArea();
/**
* Get the perimeter of this Shape.
* @return the perimeter of this Shape
*/
public abstract double getPerimeter();
}