![]() Public static int currentPlayer // CROSS, NOUGHT Public static int board = new int // EMPTY, CROSS, NOUGHT Public static final int ROWS = 3, COLS = 3 // number of rows/columns Cell contents: using CROSS, NOUGHT and NO_SEED * All variables/methods are declared as static (i.e., class) * Tic-Tac-Toe: Two-player, console-based, non-graphics, non-OO version. Player 'O' won! TTTConsoleNonOO.java import Player 'O', enter your move (row column): 2 1 Player 'X', enter your move (row column): 2 3 Player 'X', enter your move (row column): 2 2 This move at (2,2) is not valid. Player 'O', enter your move (row column): 3 1 Player 'X', enter your move (row column): 1 3 Player 'O', enter your move (row column): 1 1 ![]() Player 'X', enter your move (row column): 2 2 ![]() Let us start with a 2-player console (non-graphics) version of Tic-Tac-Toe, where player 'X' and player 'O' enter their moves successively, as shown below: Let's Start with a 2-Player Console Non-OO Tic-Tac-Toe A game can be programmed as a finite state machine, with clearly defined states and state transistion functions, as follows:įor this Tic-tac-toe, I shall try to closely follow this state diagram.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |