/*  Rectangle.java
 * Implements methods for rectangular geometric objects
 */

public class Rectangle extends Geometric {
  // declaration of instance variables
  private double lengthA;
  private double lengthB;
  private double angle;
  
  // two constructors with diff. arguments
  public Rectangle(double lengthA, double lengthB) {
    this.lengthA = lengthA;
    this.lengthB = lengthB;
    this.angle = 90.0;
    computeArea();
    computeExtend();
  }
  public Rectangle(double lengthA, double lengthB, double angle) {
    this.lengthA = lengthA;
    this.lengthB = lengthB;
    this.angle = angle;
    computeArea();
    computeExtend();
  }
  
  // now we implement the two abstract methods and 
  // calculate the area and extend
  public void computeArea() {
    area = lengthA * 
           lengthB *
	   Math.sin(Math.PI/180.0 * angle);
  }
  public void computeExtend() {
    extend = 2.0 * lengthA +
             2.0 * lengthB;
  }

  // The last methods just prints out some variables
  public String toString() {
    return ("Length SideA = " + lengthA + "\n" +
            "Length SideB = " + lengthB + "\n" +
	    "Angle = " + angle + "\n" +
	    "Area = " + area + "  Extend = " + extend + "\n");
  }
}
