Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public boolean checkifEmpty(int fromRow, int fromColumn, int toRow,
- int toColumn, Figure[][] ChessBoard) {
- int differenceInRows = Math.abs(fromRow - toRow);
- if (differenceInRows == 1 ) {
- return true;
- }
- for (int j = 1; j < differenceInRows; j++) {
- if ((toRow < fromRow) && (toColumn > fromColumn)
- && ChessBoard[fromRow - j][fromColumn + j] == null) {
- return true;
- } else if ((toRow > fromRow) && (toColumn > fromColumn)
- && ChessBoard[fromRow + j][fromColumn + j] == null) {
- return true;
- } else if ((toRow > fromRow) && (toColumn < fromColumn)
- && ChessBoard[fromRow + j][fromColumn - j] == null) {
- return true;
- } else if ((toRow < fromRow) && (toColumn < fromColumn)
- && ChessBoard[fromRow - j][fromColumn - j] == null) {
- return true;
- }
- }
- return false;
- }
- public boolean checkifEmpty(int fromRow, int fromColumn, int toRow,
- int toColumn, Figure[][] ChessBoard) {
- int differenceInRows = Math.abs(fromRow - toRow);
- for (int j = 1; j < differenceInRows; j++) {
- if ((toRow < fromRow) && (toColumn > fromColumn)
- && ChessBoard[fromRow - j][fromColumn + j] != null) {
- return false;
- } else if ((toRow > fromRow) && (toColumn > fromColumn)
- && ChessBoard[fromRow + j][fromColumn + j] != null) {
- return false;
- } else if ((toRow > fromRow) && (toColumn < fromColumn)
- && ChessBoard[fromRow + j][fromColumn - j] != null) {
- return false;
- } else if ((toRow < fromRow) && (toColumn < fromColumn)
- && ChessBoard[fromRow - j][fromColumn - j] != null) {
- return false;
- }
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement