Requirements
P7.13 Add a method getWinner to the TicTacToe class of Section 7.8. It should return "x" or "o" to indicate a winner, or " " if there is no winner yet. Recall that a winning position has three matching marks in a row, column, or diagonal.Disclaimer
- There are many ways to solve a problem.
- I do not post codes before the due date, since that does not help you.
- Codes may be incorrect because I am also a learner like you. Use it at your discretion.
1. Your method should perform 4 checks
- Check each row.
- Check each column.
- Check top-left to bottom-right diagonal.
2. In the game runner
- Check top-right to bottom-left diagonal.
- Check for occupied space, if a space on the board is occupied, player should be prompted to select new row and column.
- Check total moves to print a draw result