mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-25 20:34:32 -08:00
MAINT: Apply pre-commit
Remove byte-order-marker pre-commit check as there would be many adjustments necessary
This commit is contained in:
@@ -11,8 +11,8 @@ public class Board {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* Place 'X' or 'O' on the board position passed
|
||||
* @param position
|
||||
* @param player
|
||||
@@ -26,13 +26,13 @@ public class Board {
|
||||
}
|
||||
|
||||
public void printBoard() {
|
||||
System.out.format("%-3c ! %-3c ! %-3c\n----+----+----\n%-3c ! %-3c ! %-3c\n----+----+----\n%-3c ! %-3c ! %-3c\n",
|
||||
System.out.format("%-3c ! %-3c ! %-3c\n----+----+----\n%-3c ! %-3c ! %-3c\n----+----+----\n%-3c ! %-3c ! %-3c\n",
|
||||
this.arr[0], this.arr[1], this.arr[2], this.arr[3], this.arr[4], this.arr[5], this.arr[6], this.arr[7], this.arr[8]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* @param x
|
||||
* @return the value of the char at a given position
|
||||
*/
|
||||
@@ -40,37 +40,37 @@ public class Board {
|
||||
return arr[x-1];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* Go through the board and check for win (horizontal, diagonal, vertical)
|
||||
* @param player
|
||||
* @return whether a win has occured
|
||||
*/
|
||||
public boolean checkWin(char player) {
|
||||
if(this.arr[0] == player && this.arr[1] == player && this.arr[2] == player)
|
||||
if(this.arr[0] == player && this.arr[1] == player && this.arr[2] == player)
|
||||
return true;
|
||||
|
||||
|
||||
if(this.arr[3] == player && this.arr[4] == player && this.arr[5] == player)
|
||||
return true;
|
||||
|
||||
|
||||
if(this.arr[6] == player && this.arr[7] == player && this.arr[8] == player)
|
||||
if(this.arr[3] == player && this.arr[4] == player && this.arr[5] == player)
|
||||
return true;
|
||||
|
||||
|
||||
|
||||
if(this.arr[6] == player && this.arr[7] == player && this.arr[8] == player)
|
||||
return true;
|
||||
|
||||
if(this.arr[0] == player && this.arr[4] == player && this.arr[8] == player)
|
||||
return true;
|
||||
|
||||
|
||||
if(this.arr[2] == player && this.arr[4] == player && this.arr[6] == player)
|
||||
return true;
|
||||
|
||||
if(this.arr[0] == player && this.arr[3] == player && this.arr[6] == player)
|
||||
if(this.arr[0] == player && this.arr[3] == player && this.arr[6] == player)
|
||||
return true;
|
||||
|
||||
if(this.arr[1] == player && this.arr[4] == player && this.arr[7] == player)
|
||||
if(this.arr[1] == player && this.arr[4] == player && this.arr[7] == player)
|
||||
return true;
|
||||
|
||||
if(this.arr[2] == player && this.arr[5] == player && this.arr[8] == player)
|
||||
if(this.arr[2] == player && this.arr[5] == player && this.arr[8] == player)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
@@ -80,9 +80,9 @@ public class Board {
|
||||
if(this.getBoardValue(1) != ' ' && this.getBoardValue(2) != ' ' && this.getBoardValue(3) != ' ' && this.getBoardValue(4) != ' ' && this.getBoardValue(5) != ' ' && this.getBoardValue(6) != ' ' && this.getBoardValue(7) != ' ' && this.getBoardValue(8) != ' ' && this.getBoardValue(9) != ' ' ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Reset the board
|
||||
|
||||
@@ -147,9 +147,9 @@ public class TicTacToe2 {
|
||||
System.out.println("THATS NOT 'Y' OR 'N', TRY AGAIN");
|
||||
in.nextLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user