/* * File: QuadrilateralTest2.java * * Drawing quadrilaterals (an exercise) * * Copyright: Northeast Parallel Architectures Center * */ import java.applet.Applet; import java.awt.Graphics; public class QuadrilateralTest2 extends Applet { // create references to four quadrilaterals: private Quadrilateral quad1, quad2, quad3, quad4; public void init() { // instantiate a rectangle (a kind of quadrilateral): quad1 = new Quadrilateral( 25, 25, 125, 25, 125, 75, 25, 75 ); // instantiate a parallelogram (another kind of quadrilateral): quad2 = new Quadrilateral( 165, 25, 265, 25, 250, 75, 150, 75 ); // instantiate a square (a kind of rectangle): quad3 = new Quadrilateral( 50, 100, 100, 100, 100, 150, 50, 150 ); // instantiate a rhombus (a kind of parallelogram): quad4 = new Quadrilateral( 195, 110, 245, 110, 215, 150, 165, 150 ); } public void paint( Graphics g ) { // draw the first quadrilateral: quad1.draw( g ); // fill the second quadrilateral: quad2.fill( g ); // draw the third quadrilateral: quad3.draw( g ); // fill the fourth quadrilateral: quad4.fill( g ); } }