Source of Rectangle.java


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