// Aaron Tan
// MyRectangle.java
// Define MyRectangle class with 2 data members which are 
// the opposite vertices. A MyRectangle object is assumed 
// to have sides parallel to the x- or y-axis.

import java.awt.*;

public class MyRectangle {

   private Point pt1, pt2;  // the opposite vertices of a rectangle

   /********************************************************/

   // Create a default MyRectangle object with 
   // vertices at (0,0), and (1,1)
   public MyRectangle() {
      this(0, 0, 1, 1);
   }

   // Copies a MyRectangle object rect
   // Q: Why is the (int) type cast needed?
   public MyRectangle(MyRectangle rect) {
      this((int) rect.pt1.getX(), (int) rect.pt1.getY(), 
           (int) rect.pt2.getX(), (int) rect.pt2.getY());

      // Note that since data members (x and y) of Point
      // are public, we can also write this:
      // this(rect.pt1.x, rect.pt1.y, rect.pt2.x, rect.pt2.y);
       
   }

   // Create a MyRectangle object with vertices 
   // specified by the parameters
   public MyRectangle(Point pt1, Point pt2) {
      this((int) pt1.getX(), (int) pt1.getY(), 
           (int) pt2.getX(), (int) pt2.getY());

      // As explained above, we may also write this:
      // this(pt1.x, pt1.y, pt2.x, pt2.y);
   }

   // Create a MyRectangle object with vertices 
   // at positions specified by the parameters
   public MyRectangle(int pt1X, int pt1Y, int pt2X, int pt2Y) {
      this.pt1 = new Point(pt1X, pt1Y);
      this.pt2 = new Point(pt2X, pt2Y);
   }

   /********************************************************/

   // To display string representation of a MyRectangle object
   public String toString() {
      return "(" + this.pt1 + ", " + this.pt2 + ")";
   }

   /********************************************************/

   // To compute the area of a MyRectangle object
   // This is a stub
   public int computeArea() {
      return -1;
   }

}


