// TriangleTester2.java // Tests user-defined class Triangle // Tests three overloaded constructors import java.awt.*; import java.applet.Applet; public class TriangleTester2 extends Applet { Point point1, point2, point3, point4, point5, point6; Triangle tri1, tri2, tri3, tri4; Color bg1, bg2, bg3; public void init( ) { point1 = new Point( 50, 60 ); point2 = new Point( 200, 60 ); point3 = new Point( 125, 250 ); point4 = new Point( 200, 155 ); point5 = new Point( 280, 130 ); point6 = new Point( 260, 190 ); bg1 = new Color( 139, 0, 139 ); // dark magenta bg2 = new Color( 0, 139, 139 ); // dark cyan bg3 = new Color( 139, 139, 0 ); // olive tri1 = new Triangle( point1, point2, point3 ); tri2 = new Triangle( point4, point5, point6 ); tri3 = new Triangle( 125, 300, 50, 360, 10, 180 ); tri4 = new Triangle( 70, 90, 80, 30 ); } public void paint( Graphics g ) { g.drawString( tri1.toString( ), 2, 20 ); tri1.fill( g, bg1 ); tri1.sketch( g ); tri2.fill( g, bg2 ); tri2.sketch( g ); tri3.fill( g, bg3 ); tri3.sketch( g ); tri4.fill( g, Color.blue ); tri4.sketch( g ); point1 = new Point( 80, 90 ); point2 = new Point( 200, 100 ); tri1.setPointA( point1 ); tri1.setPointB( point2 ); tri1.fill( g, Color.yellow ); tri1.sketch( g ); tri3.setPointA( 145, 320 ); tri3.setPointB( 70, 380 ); tri3.setPointC( 30, 210 ); tri3.fill( g, Color.green ); tri3.sketch( g ); tri4.setPointA( 200, 200 ); tri4.setPointB( 200, 200, 80, 30 ); tri4.setPointC( 200, 200, 80, 30 ); tri4.fill( g, Color.red ); tri4.sketch( g ); } }