1  /*
  2   *  File:  Hexagon.java
  3   *
  4   *  Hexagon class
  5   *
  6   *  Copyright:  Northeast Parallel Architectures Center
  7   *  
  8   */
  9  
 10  import java.awt.Polygon;
 11  import java.awt.Point;
 12  
 13  // A hexagon is a polygon with six sides:
 14  class Hexagon extends MyPolygon {
 15  
 16     // Hexagon constructor #1:
 17     public Hexagon() {
 18        // invoke the constructor of the superclass MyPolygon:
 19        super();
 20     }
 21  
 22     // Hexagon constructor #2:
 23     public Hexagon( int x1, int y1, 
 24                     int x2, int y2, 
 25                     int x3, int y3, 
 26                     int x4, int y4,
 27                     int x5, int y5, 
 28                     int x6, int y6  ) {
 29   
 30        // invoke the constructor of the superclass MyPolygon:
 31        super();
 32        
 33        // the 'this' reference is optional:
 34        this.addPoint( x1, y1 );
 35        this.addPoint( x2, y2 );
 36        this.addPoint( x3, y3 );
 37        this.addPoint( x4, y4 );
 38        this.addPoint( x5, y5 );
 39        this.addPoint( x6, y6 );
 40   
 41     }
 42  
 43     // Hexagon constructor #3:
 44     public Hexagon( Point p1, 
 45                     Point p2, 
 46                     Point p3, 
 47                     Point p4,
 48                     Point p5, 
 49                     Point p6  ) {
 50   
 51        // invoke Hexagon constructor #2:
 52        this( p1.x, p1.y, p2.x, p2.y, p3.x, p3.y,
 53              p4.x, p4.y, p5.x, p5.y, p6.x, p6.y  );
 54   
 55     }
 56  
 57  }