/** A program for testing the Rectangle class and the TwoDPoint class.
    Save the program in a file named TestRectangle.java, and have two 
    java files TwoDPoint.java, Rectangle.java in the same directory.  
    Compile them using the javac commands javac TwoDPoint.java, 
    javac Rectangle.java, and javac TestRectangle.java, then run the 
    test with the command java TestRectangle. 
    Note: Put this java file on your disk along with the other 2 java 
          files when turning in the assignment */
public class TestRectangle {  
  public static void main(String args[]) {
    // create a Rectangle r1 and print something about it
    TwoDPoint p1 = new TwoDPoint(2, 3);
    Rectangle r1 = new Rectangle(p1, 20, 10);
    System.out.println("r1's upper-left: " + r1.getUpperLeft().toString());
    System.out.println("r1 has: " + r1.toString());

    // create 3 other Rectangle objects r2 - r4
    TwoDPoint p2 = new TwoDPoint(10, 5);
    Rectangle r2 = new Rectangle(p2, 5, 10);
    Rectangle r3 = r1.translate(20, 2);  // test translate()
    p2 = new TwoDPoint(1, 14);
    Rectangle r4 = new Rectangle(p2, 10, 6);

    // print something about the Rectangle objects
    System.out.println("r3's upper-left: " + r3.getUpperLeft().toString());
    System.out.println("r1's upper-left: " + r1.getUpperLeft().toString());
    System.out.println("r4's length = " + r4.getLength() + 
                       ", width = " + r4.getWidth() + ", area = " 
                       + r4.area());
    
    // test the intersect() method
    if (r1.intersect(r2))
      System.out.println("r1 and r2 overlap");
    else
      System.out.println("r1 and r2 do not overlap");
    if (r1.intersect(r3))
      System.out.println("r1 and r3 overlap");
    else
      System.out.println("r1 and r3 do not overlap");
    if (r2.intersect(r3))
      System.out.println("r2 and r3 overlap");
    else
      System.out.println("r2 and r3 do not overlap");
    if (r4.intersect(r2))
      System.out.println("r4 and r2 overlap");
    else
      System.out.println("r4 and r2 do not overlap");
    if (r1.intersect(r4))
      System.out.println("r1 and r4 overlap");
    else
      System.out.println("r1 and r4 do not overlap");    
  }
}
