umar_ahmad

bishop1.java

Feb 28th, 2020
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. package chess;
  2.  
  3. public class Bishop extends Piece{
  4. public Bishop(PieceColour colour){
  5. this.colour = colour;
  6. if (colour == PieceColour.WHITE){
  7. setSymbol("\u2657");
  8. }
  9. else {
  10. setSymbol("\u265D");
  11. }
  12. }
  13.  
  14. @Override
  15. public boolean isLegitMove(int iIn, int jIn, int iOut, int jOut){
  16. if (iIn==iOut || jIn==jOut){
  17. return false;
  18. }
  19. if (jOut-jIn == iOut-iIn){
  20. for(int x = jOut-jIn-1; x>0; x--){
  21. if (Board.getBoard()[iIn+x][jIn+x].hasPiece()){
  22. return false;
  23. }
  24. else{
  25. return true;
  26. }
  27. }
  28. }
  29. if (jIn-jOut == iOut-iIn){
  30. for(int x = jIn-jOut-1; x>0; x--){
  31. if (Board.getBoard()[iIn+x][jIn-x].hasPiece()){
  32. return false;
  33. }
  34. else{
  35. return true;
  36. }
  37. }
  38. }
  39. if (jOut-jIn == iIn-iOut){
  40. for(int x = jOut-jIn-1; x>0; x--){
  41. if (Board.getBoard()[iIn-x][jIn+x].hasPiece()){
  42. return false;
  43. }
  44. else{
  45. return true;
  46. }
  47. }
  48. }
  49. if (jIn-jOut == iIn-iOut){
  50. for(int x =jIn-jOut-1; x>0; x--){
  51. if (Board.getBoard()[iIn-x][jIn-x].hasPiece()){
  52. return false;
  53. }
  54. else{
  55. return true;
  56. }
  57. }
  58. }
  59.  
  60. return false;
  61. }
  62.  
  63. }
Add Comment
Please, Sign In to add comment