Source of Rectangle.java


  1: //Rectangle.java

  3: /** 
  4:  * A class of rectangles.
  5: */
  6: public class Rectangle implements Measurable
  7: {
  8:     private double myWidth;
  9:     private double myHeight;
 10:     public Rectangle(double width, double height)
 11:     {
 12:         myWidth = width;
 13:         myHeight = height;
 14:     }
 15:     public double getPerimeter()
 16:     {
 17:         return 2 * (myWidth + myHeight);
 18:     }
 19:     public double getArea()
 20:     {
 21:         return myWidth * myHeight;
 22:     }
 23: }