5 * $Id: Shape.java,v 1.1 2007/08/16 19:10:01 vcss232 Exp $
9 * Revision 1.1 2007/08/16 19:10:01 vcss232
15 * Shape is an abstract class to implement a basic shape.
17 * @author Karen A Atkinson
21 abstract public class Shape
extends Object
{
23 private double xPos
; // x position of shape
24 private double yPos
; // y position of shape
27 * Construct the shape at the specified position
29 * @param xLoc x location for shape
30 * @param yLoc y location for shape
33 public Shape( double xLoc
, double yLoc
) {
39 * Compute the area of the shape.
41 * @return the area of the shape
44 abstract public double area();
47 * Stretches the size of the shape by multiplying
48 * each of the dimensions of the shape by the factor
49 * provided. For example, if the factor is .5, then each of
50 * the dimensions would be cut in half.
52 * @param factor factor to stretch by
54 * @exception ShapeException Exception thrown by subclass for negative
58 abstract public void stretchBy( double factor
) throws ShapeException
;
61 * Return the x coordinate of the current location of the shape.
63 * @return x coordinate of the shape
66 public final double getXPos() {
71 * Return the y coordinate of the current location of the shape.
73 * @return y corrdinate of the shape
76 public final double getYPos() {
81 * Move the shape to a new location.
83 * @param xLoc new X location
84 * @param yLoc new Y location
88 public void moveTo( double xLoc
, double yLoc
) {
94 * Return a string representation of this shape.
96 * @return a string representation of this shape.
100 public String
toString() {