I don't think they had regex when I made mine, but they might have. Here was the algo's that I used:
Remember, there is not just one way to solve a problem. I am sure there a ton of different ways to make a tic tac toe game without using regexCode:private boolean hasWon(int x, int y) { boolean won; won = true; for (int col=0; col<3; col++) { if (!btn[x][col].getText().equals(player)) { won = false; } } if (!won) { won = true; for (int row=0; row<3; row++) { if (!btn[row][y].getText().equals(player)) { won = false; } } } if (!won) { won = true; for (int num=0; num<3; num++) { if (!btn[num][num].getText().equals(player)) { won = false; } } } if (!won) { won = true; for (int num=0; num<3; num++) { if (!btn[2-num][num].getText().equals(player)) { won = false; } } } return won; }




Reply With Quote