- Read these instructions repeatedly until you understand, then begin your project. If something is not clear, ask.
- Log in to GitHub.
- Fork this repo(sitory). See this video on how to carry out this step and step
3
. - Clone your fork, using either the web site or the GitHub Desktop client.
- Checkout your personalized branch, the one with your name and GitHub handle.
Using basic Java graphics via the Processing programming language, create a tic tac toe game in which the user plays against the computer. A short movie of how this assignment should look and behave in its resolved state is available here.
- The size of the canvas must be 500×500.
- The computer always plays an “X”.
- The user always renders a circle.
- The computer always starts.
- Any content that should be reported to the user must be done via Processing’s
println()
method. - Use only the numeric keys 0–8 to choose a square. The number 0 must map to the top left corner square, then assign the subsequent numbers across the top and down until you reach the bottom right corner square, which must map to the number 8.
- When the user presses any key between 0–8 that corresponds to a blank square, your program should fill that square with a circle. This is akin to the user taking a turn at the game.
- Immediately after the user plays, the computer takes its turn.
- When the user presses any key other than 0–8, your program should report a message to the user that they pressed an incorrect key.
- After the user takes their turn, and if neither the user nor the computer has won, report to the user that the game is still in play.
- If all squares are played and neither the computer nor the user has won, report to the user that no one has won.
- When either the user or the computer has won, report this to the user.
- Subsequent key presses after a game has ended should report to the user that the game has ended.
This repo contains the following files, all required to carry out this assignment. Before you start working, ensure you understand the role of each file below.
tic_tac_toe/tic_tac_toe.pde
— This is the springboard from where your Processing app will run usingsetup()
anddraw()
.tic_tac_toe/constants.pde
— All global constants must go in this file.tic_tac_toe/shapes.pde
— All methods you author to draw shapes, such as “O”, “X”, and the tic tac toe board must go in this file.tic_tac_toe/board.pde
— The logic of your program goes in this file. That is, all methods that will process the logic of your tic tac toe game..editorconfig
— The settings in this version of.editorconfig
by default indents code by 2 spaces. If you use VS Code instead of Processing to write code for this project, ensure EditorConfig is working before beginning this assignment. (The Processing IDE by default also indents by 2 spaces.).gitignore
— Do not modify any .gitignore files.
All your code may only be written in the .pde
files discussed above.
Item | Points |
---|---|
Program works according to instructions | 20 |
Code avoids being clever in favor of readability | 20 |
Code is neat and professional | 20 |
Variable naming is logical | 20 |
Comments are used thoughtfully in places where code is not self documenting | 20 |
Wednesday, 13 December 2023, at 12:00 PM.
You will need to issue a pull request back into the original repo, the one from which your fork was created for this project. See the Issuing Pull Requests section of this site for help on how to submit your assignment.
Note: This assignment may only be submitted via GitHub. No other form of submission will be accepted.