1  /*
  2   *  File:  MyTriangle.java
  3   *
  4   *  Triangle class
  5   *
  6   *  Copyright:  Northeast Parallel Architectures Center
  7   *  
  8   */
  9  
 10  import java.awt.Point;
 11  
 12  // A triangle is a polygon with three sides:
 13  class MyTriangle extends MyPolygon {
 14  
 15     // Triangle constructor #1:
 16     public MyTriangle() {
 17        // invoke the constructor of the superclass Polygon:
 18        super();
 19     }
 20  
 21     // Triangle constructor #2:
 22     public MyTriangle( int x1, int y1, 
 23                        int x2, int y2, 
 24                        int x3, int y3  ) {
 25   
 26        // invoke the constructor of the superclass Polygon:
 27        super();
 28   
 29        // the 'this' reference is optional:
 30        this.addPoint( x1, y1 );
 31        this.addPoint( x2, y2 );
 32        this.addPoint( x3, y3 );
 33   
 34     }
 35  
 36     // Triangle constructor #3:
 37     public MyTriangle( Point p1, Point p2, Point p3 ) {
 38   
 39        // invoke Triangle constructor #2:
 40        this( p1.x, p1.y, p2.x, p2.y, p3.x, p3.y  );
 41   
 42     }
 43  
 44  }