Advertisement
umar_ahmad

square.java

Feb 28th, 2020
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. package chess;
  2.  
  3.  
  4. //This class is partially implemented
  5. public class Square {
  6. private int i;
  7. private int j;
  8. private boolean hasPiece;
  9. private Piece p;
  10.  
  11. public Square(int iIn, int jIn){
  12. i=iIn;
  13. j=jIn;
  14. }
  15.  
  16. public Piece getPiece(){
  17. return p;
  18. }
  19.  
  20. public void setPiece(Piece p){
  21. this.p = p;
  22. p.updateCoordinates(i, j);
  23. }
  24.  
  25. public void removePiece(){
  26. this.p = null;
  27. hasPiece = false;
  28. }
  29.  
  30. public boolean hasPiece(){
  31. if (p == null){
  32. return false;
  33. }
  34. else{
  35. return true;
  36. }
  37. }
  38.  
  39. public int getI(){
  40. return i;
  41. }
  42.  
  43. public int getJ(){
  44. return j;
  45. }
  46.  
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement