Subato

IsoscelesTriangle in Swing

package name.panitz.oose;

public class IsoscelesTriangle extends PolygonObject {

  double legLength;

  public IsoscelesTriangle(Vertex corner, double baseLength,
      double legLength, Vertex velocity) {
    super(corner, baseLength,
        Math.sqrt(Math.pow(legLength, 2)-Math.pow(baseLength/2,2)), velocity);
    this.legLength = legLength;
    initPolygon();
  }

  @Override
  void initPolygon() {
    p.add(0, height);
    p.add(width, height);
    p.add(width/2, 0);
  }
  @Override
  public String toString() {
    return "new IsoscelesTriangle(new Vertex"+corner
        +", "+width+", "+legLength+", new Vertex"+velocity+")";
  }

  @Override
  double size() {
    return width*height/2.0;
  }
}