/* * File: Quadrilateral.java * * Quadrilateral class * * Copyright: Northeast Parallel Architectures Center * */ import java.awt.Polygon; import java.awt.Graphics; // A quadrilateral is a polygon with four sides: public class Quadrilateral extends Polygon { // Quadrilateral constructor #1: public Quadrilateral() { // invoke the constructor of the superclass Polygon: super(); } // Quadrilateral constructor #2: public Quadrilateral( int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4 ) { // invoke the constructor of the superclass Polygon: super(); // the 'this' reference is optional: this.addPoint( x1, y1 ); this.addPoint( x2, y2 ); this.addPoint( x3, y3 ); this.addPoint( x4, y4 ); } // Instance methods: public void draw( Graphics g ) { g.drawPolygon( this ); } public void fill( Graphics g ) { g.fillPolygon( this ); } }