CS 257: Software Design

TTT3D, Phase 3 of 3

Continue with your partner, one more time.

For this assignment, you will complete an implementation of the TTT3DMover class, along with a command-line application to give it a try, as described below.

The TTT3DMoverTest class from phase 2 time will be a big help, but you will now need to implement TTT3DMover, add facilities for parsing the command line arguments, mechanisms for loading example TTT3D boards from a file, etc. You'll add a main method to TTT3DMover to enable you to run TTT3DMover as an independent program (unlike with Phase 2, where you used the JUnit test infrastructure to instantiate objects and invoke methods).

TTT3DMover's command-line syntax

java TTT3DMover action boardFile

where action can have any of the values win, block, or force, and boardFile is the name of an ASCII text file containing a representation of a 3D tic-tac-toe board. Depending on the action selected, your application should print to standard output a human-readable display of the specified board, with asterisks placed in any position where a win, block, or force can take place given the board's next player.

The file format for a board consists of five lines of text. The first four lines should represent the four rows of the 3D tic-tac-toe board, with X's, O's, hyphens (-, to represent an empty square), and space characters (for human readability). The fifth line should contain only an X or an O, to indicate whose turn it is. For example:

XO-- X--- X--- ---- X--- ---- ---- ---- ---- -O-- ---- -O-- XO-- ---- ---- ---- O

represents a board where X has taken 4 turns, O has taken three turns, and it's O's turn now. You may use space characters in any way you wish, and should make sure your file input routine ignores spaces. But any characters other than X, O, -, space, or newline should be considered illegal characters, generating an exception of some kind.

Usage examples

For each of the following examples, assume board.txt contains the board shown above.

Notes

Handing it in

Submit your program by committing it to your GitHub repository and tagging it with a tag named "ttt3d_phase3".

Have fun!