Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void checkWinDiagonal() {
- int rowStart = 0;
- int colStart = 0;
- int rowMax = 6;
- int colMax = 7;
- for (rowStart = 0; rowStart < rowMax; rowStart++) {
- int redCounter = 0;
- int yellowCounter = 0;
- int row, col;
- for (row = rowStart, col = 0; row < rowMax && col < colMax; row++, col++) {
- if (boardData[row][col] == Token.RED) {
- redCounter++;
- if (redCounter >= 4) {
- System.out.println("Red Player wins!");
- }
- } else if (boardData[row][col] == Token.YELLOW) {
- yellowCounter++;
- if (yellowCounter >= 4) {
- System.out.println("Yellow Player wins!");
- }
- } else {
- redCounter = 0;
- yellowCounter = 0;
- }
- }
- }
- for (colStart = 1; colStart < colMax; rowStart++) {
- int redCounter = 0;
- int yellowCounter = 0;
- int row, col;
- for (row = 0, col = colStart; row < rowMax && col < colMax; row++, col++) {
- if (boardData[row][col] == Token.RED) {
- redCounter++;
- if (redCounter >= 4) {
- System.out.println("Red Player wins!");
- }
- } else if (boardData[row][col] == Token.YELLOW) {
- yellowCounter++;
- if (yellowCounter >= 4) {
- System.out.println("Yellow Player wins!");
- }
- } else {
- redCounter = 0;
- yellowCounter = 0;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement