/* * File: Hexagon.java * * Hexagon class * * Copyright: Northeast Parallel Architectures Center * */ import java.awt.Point; // A hexagon is a polygon with six sides: public class Hexagon extends MovablePolygon { // Hexagon constructor #1: public Hexagon() { // invoke the no-argument constructor of the superclass: super(); } // Hexagon constructor #2: public Hexagon( int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4, int x5, int y5, int x6, int y6 ) { // invoke the no-argument constructor of the superclass: super(); // the 'this' reference is optional: this.addPoint( x1, y1 ); this.addPoint( x2, y2 ); this.addPoint( x3, y3 ); this.addPoint( x4, y4 ); this.addPoint( x5, y5 ); this.addPoint( x6, y6 ); } // Hexagon constructor #3: public Hexagon( Point p1, Point p2, Point p3, Point p4, Point p5, Point p6 ) { // invoke Hexagon constructor #2: this( p1.x, p1.y, p2.x, p2.y, p3.x, p3.y, p4.x, p4.y, p5.x, p5.y, p6.x, p6.y ); } // Hexagon constructor #4 (a regular hexagon centered // at point (x,y) of radius r ): public Hexagon( int x, int y, int r ) { // invoke the corresponding constructor of the superclass: super( x, y, r, 6 ); } }