Must be done in Java and use the StdDraw.java file.

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

Must be done in Java and use the StdDraw.java file.

Post by answerhappygod »

Must be done in Java and use the StdDraw.java file.
Must Be Done In Java And Use The Stddraw Java File 1
Must Be Done In Java And Use The Stddraw Java File 1 (157.27 KiB) Viewed 42 times
Must Be Done In Java And Use The Stddraw Java File 2
Must Be Done In Java And Use The Stddraw Java File 2 (163.28 KiB) Viewed 42 times
TicTacToeStarter.zip Build a simple Tic-Tac-Toe game ("Xs and Os"). The game must be drawn using the attached StdDraw class (StdDraw.java ) and the users should click on the window using the mouse input (also in the StdDraw library) to select their squares each turn. The game should maintain a valid board at all times and report a winner/loser/tie at the end of the game (correctly determining when the game has ended). The game should be played by 2 human players (you don't need to do a computer Al player for this program). Assume the two players are taking turns and clicking on their chosen squares. Only mark the board with the player's symbol according to their turn, when they click on an empty square. You can mark the squares however you like, just use 2 distinct markings (like the traditional X and O, for example). See the demo video and starter code for ideas/hints about what you need to do. Demo video: Tic-Tac-Toe Game Demo e If you're having trouble getting started with the Tic-Tac-Toe program, here is some sample code that might help you. It focuses on drawing a little and also getting a mouse-press from the user: GetStarted.java

Notes/Hints: + You will need to keep track of which squares are occupied (and by which player) and which squares are available. One possibility is a two-dimensional array (3x3) of integers. A value of 0 could be empty, a value of 1 could be player 1, and a value of 2 could be player 2. + Starting with the 5th turn (player 1's third turn) you should start checking to see if the current player wins with their turn. As soon as a win is detected (3 in a row, 3 in a column, 3 in a diagonal), the game is over. Print a message or mark the board to show this, and do not allow any further turns. + After 9 turns the game is over, either with player 1 getting a win on their last (5th) turn or with no winner, a draw. Print a message or mark the board to show this, and do not allow any further turns. + Create your program in stages. Start | making the board. Then work on marking squares with clicks and keeping track of the turns. Then start looking to detect wins and draws. Don't try to code everything all at once, and test your program as you go. Once you've got a working game, play it yourself (or with someone else!) a few times to make sure it works correctly. When you are done, submit your completed source code file (.java file) for your program. You do not need to submit the StdDraw.java file, I already have that.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply