// OverloadedMethods.java
// Example of using overloadedMethods
// APPLET CODE="OverloadedMethods" HEIGHT=200 WIDTH=550
import java.awt.*;
import javax.swing.*;

public class OverloadedMethods extends JApplet {
	JTextArea outputArea;
	int area;
	int x1, x2, y1, y2;
	Point topLeft, bottomRight;

	public void init( ) {
		outputArea = new JTextArea( 4, 40 );
		Container c = getContentPane( );
		c.add( outputArea );

		x1 = 10;
		x2 = 110;
		y1 = 25;
		y2 = 325;
		topLeft = new Point( x1, y1 );
		bottomRight = new Point( x2, y2 );
		int width = x2 - x1;
		int length = y2 - y1;

		outputArea.setText( "Given the four coordinates, the area of a rectangle " + ( x2 - x1 ) + " by " + ( y2 - y1 ) + " is " + rectArea( x1, x2, y1, y2 ) + "." +
				     "\nGiven the top left corner and the width and length, the area of a rectangle " + ( x2 - x1 ) + " by " + ( y2 - y1 ) + " is " + rectArea( topLeft, width, length ) + "." +
				     "\nGiven the diagonally opposite corners, the area of a rectangle " + ( x2 - x1 ) + " by " + ( y2 - y1 ) + " is " + rectArea( topLeft, bottomRight ) + "." );
	}

	int rectArea( int xCoord1, int xCoord2, int yCoord1, int yCoord2 ) {
		return ( xCoord2 - xCoord1 ) * ( yCoord2 - yCoord1 );
	}

	int rectArea( Point upperLeft, int w, int l ) {
		return w * l;
	}

	int rectArea( Point upperLeft, Point lowerRight ) {
		return ( lowerRight.x - upperLeft.x ) * ( lowerRight.y - upperLeft.y );
	}
}