A Rectangle is ... 

Define a class that models that. 

Please teach Rectangle objects to detect overlap. 

What is a Point? 

public class Point {
  private int x, y; 
  public Point(int x, int y) {
    this.x = x;
    this.y = y; 
  }
  public double distanceTo(Point other) {
    int dx = this.x - other.x; 
    int dy = this.y - other.y;
    return Math.sqrt( Math.pow(dx, 2) + Math.pow(dy, 2) ); 
  }
  public static void main(String[] args) {
    Point a = new Point(0, 0);
    Point b = new Point(1, 1); 
    System.out.println( a.distanceTo(b) ); // 1.4142135623... 
  }
}

What's a Line?

public class Line {
  private Point indianapolis, bloomington;  
  public Line(Point a, Point b) {
    this.indianapolis = a; 
    this.bloomington = b; 
  }
  public double length() {
    return indianapolis.distanceTo(bloomington);  
  }
  public static void main(String[] args) {
    Line a = new Line(new Point(0, 1), new Point(1, 0));
    System.out.println( a.length() ); // 1.4142135623... 
  }
}

What's a Triangle? 

public class Triangle {
  private Line a, b, c; 
  public Triangle(Point a, Point b, Point c) {
    this.a = new Line(b, c);  
    this.b = new Line(a, c);  
    this.c = new Line(a, b);  
  }
  public double area() {
    ...  
  }
  public static void main(String[] args) {
    Triangle t = new Triangle( ... , 
                               ... ,
                               ... ); 
    System.out.println( t.area() ); 
  }
}

What's the formula that we need to use for the area? 

     base * height
A = ---------------
          2 

Chris H, Sunghyun, Jerry S, Joe B, Arthi, Haoyang, Vanessa, Kayl, Jared, 

Mike C, He He, Xinyu, Sid, Seth, Jiahao, Arif, David, Zhiwei, Rerajitha, 

Brandon, Andrew R, Andrew T, Kevin S, Kevin J W A, Chenrui He, Alex Q, 

Levi R, Alex Stilian, Jiebo, Zach H, Rajeev, Keqin and Yinan and Mr. Heron 

Was Matt L. here? Yes.

public class Triangle {
  private Line a, b, c; 
  public Triangle(Point a, Point b, Point c) {
    this.a = new Line(b, c);  
    this.b = new Line(a, c);  
    this.c = new Line(a, b);  
  }
  public double area() {
    double a, b, c, s;
    a = this.a.length(); 
    b = this.b.length(); 
    c = this.c.length(); 
    s = (a + b + c) / 2; 
    return Math.sqrt( s * (s - a) * (s - b) * (s - c) ); 
  }
  public static void main(String[] args) {
    Triangle t = new Triangle( new Point(0, 0) , 
                               new Point(0, 3) ,
                               new Point(4, 0) ); 
    System.out.println( t.area() ); // 
  }
}

So now the question what is a good model for a Rectangle? 

https://en.wikipedia.org/wiki/Heron%27s_formula

--

In lab we need to define two overlaps methods (a static and a non-static one).