JAVA   26
Coordinates
Guest on 13th March 2023 01:18:17 PM


  1. public class Coordinates
  2. {
  3.    int x;
  4.    int y;
  5.  
  6.    public Coordinates(int xIn, int yIn)
  7.    {
  8.       x = xIn;
  9.       y = yIn;
  10.    }
  11.  
  12.    public int getX()
  13.    {
  14.       return x;
  15.    }
  16.  
  17.    public int getY()
  18.    {
  19.       return y;
  20.    }
  21.  
  22.    public String toString()
  23.    {
  24.        String s = "Coordinates: " + " x = " + x + " , y = " + y;
  25.        return s;
  26.    }
  27.  
  28.    public boolean equals(Coordinates c)
  29.    {
  30.       if(x == c.getX() && y == c.getY())
  31.          return true;
  32.       else
  33.          return false;
  34.    }
  35. }

Raw Paste

Login or Register to edit or fork this paste. It's free.