Advertisement
UniQuet0p1

Point.java

Feb 23rd, 2022
730
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.55 KB | None | 0 0
  1. package oo.hide;
  2.  
  3. import java.util.Objects;
  4.  
  5. public class Point {
  6.  
  7.     private int x;
  8.     private int y;
  9.  
  10.     public Point(int x, int y) {
  11.         this.x = x;
  12.         this.y = y;
  13.     }
  14.  
  15.     @Override
  16.     public String toString() {
  17.         return String.format("(%s, %s)", x, y);
  18.     }
  19.  
  20.     @Override
  21.     public boolean equals(Object obj) {
  22.         if (!(obj instanceof  Point)) {
  23.             return false;
  24.         }
  25.         Point  other = (Point) obj;
  26.  
  27.         return Objects.equals(x, other.x) && Objects.equals(y, other.y);
  28.     }
  29. }
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement