1 package com.myproj.snake; 2 3 public class Node { 4 private int i,j; 5 public Node(){} 6 public Node(int i, int j) { 7 super(); 8 this.i = i; 9 this.j = j; 10 } 11 12 public int getI() { 13 return i; 14 } 15 16 public void setI(int i) { 17 this.i = i; 18 } 19 20 public int getJ() { 21 return j; 22 } 23 24 public void setJ(int j) { 25 this.j = j; 26 } 27 @Override 28 public int hashCode() { 29 final int prime = 31; 30 int result = 1; 31 result = prime * result + i; 32 result = prime * result + j; 33 return result; 34 } 35 @Override 36 public boolean equals(Object obj) { 37 if (this == obj) 38 return true; 39 if (obj == null) 40 return false; 41 if (getClass() != obj.getClass()) 42 return false; 43 Node other = (Node) obj; 44 if (i != other.i) 45 return false; 46 if (j != other.j) 47 return false; 48 return true; 49 } 50 51 }
相关文章: