// APS101, Winter 2009: Lecture 28 (Mar. 19) // // Review: last time we began writing a Tic-Tac-Toe game. // This will be good practice for A3! // The first component of a game is the "engine": // the behind-the-scenes work that is done by the // program, which allows the user to play the game. // (however, it's not very user-friendly - which is // why we need to write a GUI for the game later!) // We already wrote the constructor and the setMark methods. // Now, we need to visualize the game, as follows: // empty grid: | | - - - | | - - - | | // or: X| | - - - O|O| - - - | | // Notice the repetition in this visual representation. // i.e., we can use loops to make this drawing! // (see the toString() method in TicTacToe.java) // What other functionality does a game have? // well, usually at some point one player wins the game. // How many ways are there to win in Tic-Tac-Toe? // 1) horizontally // 2) vertically // 3) diagonally // (see methods rowWinner, colWinner, and diagWinner in TicTacToe.java) // Pay special attention to the LOGIC behind your code! // we had problems writing diagWinner because of some very small // errors in the for-loops. // These are called run-time errors (as opposed to syntax errors), and // they are much harder to debug!