Lab 8

Download the code attached to the page.  It's a stripped down version of program 3, for the game TicTacToe.  For lab this week, take the version with 9 variables, and replace it with a single char array representing the board.

You will earn no points for doing so, but you should run the code with multiple variables, to get an understanding of what p0-p8 do in the code. For a single point, get rid of the 9 char variables in the sample Tic-Tac-Toe code and instead use a single 9-element char array.  Modify the print method to display the entire 3x3 board. For two points, allow the user to specify which square they want to move to, and place a piece there according to the current player, using the array. For extra credit, check for a winning condition (there are fewer of them in this game), and validate the moves (check that players only place pieces on blanks).  It's your choice whether or not you want to refund the move.

For extra practice, though no credit, try expanding the board to a variable width and height.

Submission:

You may work with a partner, and we recommend you do so.

Be sure to include all authors' names, as well as the hour of the lab.

Submit the .java file (not the .class file) to blackboard by noon on Thursday.  You have extra time now, so be sure to do a good job.  If you still want to submit by the end of lab, to be sure you remember, that would be good as well.  You may submit as many times as you like.