CMPS 13H: Honors Introduction to Programming and Data Structures

Programming Assignment #2: Tic-Tac-Toe


Remember: your programming assignment must be turned in online.

The Basics

The goal of this assignment is to write a more complex program using conditionals, loops, and methods. Arrays can be used, but are not required.

The program you are to will play tic-tac-toe with the user. It will display the board using simple console output (with System.out.print() and System.out.println()). It will implement a simple computer player, and can either allow the user to always go first or ask the user who should go first.

[For no extra credit] Modify your program to ask the user if he/she wants to play again, and play a new game if the answer is "yes".


The Details

You can get input from the user in any format you like, but be sure to print out instructions at the beginning that makes clear what that format will be. For instance, the user could input coordinates, like this "(0,0)" for upper left, or "UL" or "A" or "1", depending on what you think is best. Just make clear what you expect.

Your program should deal correctly with incorrect inputs. That means you should check the value to make sure it is valid, and output an error message and ask again for the correct input until you get a correct input. When you get an incorrect message, a helpful error message contains a description of what input was actually expected.

Your program must be accompanied by a one page ASCII document (.txt format) that shows your design:

  1. Inputs
  2. Outputs
  3. Data objects and all non-trivial operations on those data objects
  4. Algorithm(s)

Your program must also contain clear and descriptive variable names and comments, and good formatting that enhances the clarity of the program.


What to turn in

Your java program (called TicTacToe.java) and your design document (called Design.txt).

REMEMBER: Do not submit object files, assembler files, or executables. Every file in the submit directory that could be generated automatically by the compiler or assembler will result in a 5 point deduction from your programming assignment grade.


sbrandt@cse.ucsc.edu