Source of Rectangle.java


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