User Tools

Site Tools


tictactoe2

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
tictactoe2 [2020/11/03 15:03] frchristictactoe2 [2024/11/13 17:33] (current) frchris
Line 6: Line 6:
   - Complete the constructor so the board can be any size, not just 3 by 3. Read the comments for details   - Complete the constructor so the board can be any size, not just 3 by 3. Read the comments for details
   - complete the ''changePlayer'' method.   - complete the ''changePlayer'' method.
-  - complete the ''mark'' method, that puts the replaces the grid location with the letter stored in ''player'', and then calls the ''changePlayer'' method (Don't reduplicate code inside the ''mark'' method).+  - complete the ''mark'' method, that only replaces the grid location with the letter stored in ''player'' if it currently has a space.   call the ''changePlayer'' method (Don't reduplicate code inside the ''mark'' method).
   - complete the ''getPlayer'' method   - complete the ''getPlayer'' method
-  - make a method called ''movesRemaining'' that returns the number of spaces in ''grid''+  - make a method called ''movesRemaining'' that returns the number of spaces in ''grid''. Try using an enhanced ("for-each") for loop.
   - write a main method that makes an instance of the TicTacToe2 class and the calls the ''print'' method:   - write a main method that makes an instance of the TicTacToe2 class and the calls the ''print'' method:
 ''public static void main(String[] args)'' ''public static void main(String[] args)''
 +
 +At this point you can test your code with {{ :tictactoetextgame.java |TicTacToeTexGame.java}} to see if you can put "X" and "O" in all 9 squares.  Without completing the winner method, it will end with a cat's game every time.  Try making sure it does not allow overwriteing a square that already has an "X" or a "O".
  
 Next we can work on the game, and the testing the ''winner()'' method of the ''TicTacToe2'' class.  Next we can work on the game, and the testing the ''winner()'' method of the ''TicTacToe2'' class. 
tictactoe2.1604433789.txt.gz · Last modified: 2020/11/03 15:03 by frchris

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki