Guest User

Untitled

a guest
May 22nd, 2018
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.72 KB | None | 0 0
  1. package be.xios.ladadv;
  2.  
  3. public class Coordinate {
  4.     private int x;
  5.     private int y;
  6.     //constructor
  7.     public Coordinate(){
  8.         x = 0;
  9.         y = 0;
  10.     }
  11.     public Coordinate(int x, int y){
  12.         this.x =x;
  13.         this.y =y;
  14.     }
  15.     //getters
  16.     public int getX(){
  17.         return x;
  18.     }
  19.     public int getY(){
  20.         return y;
  21.     }
  22.     //setters
  23.     public void setX(int x){
  24.         this.x = x;
  25.     }
  26.     public void setY(int y){
  27.         this.y = y;
  28.     }
  29.    
  30.     public String toString(){
  31.         return "(" + x + ", " + y + ")";
  32.     }
  33.    
  34.     public boolean equals(Object o){
  35.         if (o == null){
  36.             return false;
  37.         }else if(this.getClass() != o.getClass()){
  38.             return false;
  39.         }else{
  40.             Coordinate vgl = (Coordinate) o;
  41.             return(this.x == vgl.getX() && this.y == vgl.getY());
  42.         }
  43.     }
  44. }
Add Comment
Please, Sign In to add comment