public class Point {
  private int x;
  private int y;

  public Point(int initialX, int initialY) {
    x = initialX;
    y = initialY;
  }

  public void move(int dx, int dy) {
    x+=dx;
    y+=dy;
  }

  /* mutator method */
  public void setX(int newX) {
    x=newX;
  }

  /* mutator method */
  public void setY(int newY) {
    y=newY;
  }
  
  /* accessor method */
  public int getX() {
    return x;
  }
    
  /* accessor method */
  public int getY() {
    return y;
  }
    
  public String toString() {
    return "(" + x + "," + y + ")";
  }

  /* returns true if this point has the
   * same contents as otherPoint and
   * false otherwise */
  public boolean equals(Point otherPoint) {
    if (x == otherPoint.x && y == otherPoint.y) {
      return true;
    } else {
      return false;
    }

    /* one line that does exactly the same thing */
    // return x == otherPoint.x && y == otherPoint.y;
  }
}

/* how equals would be called: */
// Point p1, p2;
// ...

// p1.equals(p2);



Point p1 = new Point(5, 5);
Point p2 = new Point(5, 5);

if (p1 == p2) {
  same
} else {
  different
}

/* compare contents */
if (p1.getX() == p2.getX() &&
    p1.getY() == p2.getY())

Toyota86GT
