kashdkjaf
[rmh3093.git] / lab3 / Shape.java
blob8596db3c3440d2219d8553d19819f6ab1aa15430
1 /*
2 * Shape.java
3 *
4 * Version:
5 * $Id: Shape.java,v 1.1 2007/08/16 19:10:01 vcss232 Exp $
6 *
7 * Revisions:
8 * $Log: Shape.java,v $
9 * Revision 1.1 2007/08/16 19:10:01 vcss232
10 * Initial revision
14 /**
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
26 /**
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 ) {
34 xPos = xLoc;
35 yPos = yLoc;
38 /**
39 * Compute the area of the shape.
41 * @return the area of the shape
44 abstract public double area();
46 /**
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
55 * factor.
58 abstract public void stretchBy( double factor ) throws ShapeException;
60 /**
61 * Return the x coordinate of the current location of the shape.
63 * @return x coordinate of the shape
66 public final double getXPos() {
67 return xPos;
70 /**
71 * Return the y coordinate of the current location of the shape.
73 * @return y corrdinate of the shape
76 public final double getYPos() {
77 return yPos;
80 /**
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 ) {
89 xPos = xLoc;
90 yPos = yLoc;
93 /**
94 * Return a string representation of this shape.
96 * @return a string representation of this shape.
100 public String toString() {
101 return "Shape";
104 } // Shape