Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Needs help with Javafx Programming Your task is to write a Java application to play the game of tic-tac-toe. The game of tic-tac-toe is played

Needs help with Javafx Programming

Your task is to write a Java application to play the game of tic-tac-toe. The game of tic-tac-toe is played on a 3x3 grid of cells. One player is designated as X and the other is O. The X player always goes first and places an X symbol on one of the nine empty cells. The O player then responds by placing an O symbol on one of the remaining unmarked cells. The players continue to alternate turns placing their symbols on open cells until one player successfully places three symbols in a horizontal, vertical, diagonal line to win the game or all the cells are filled resulting in a draw.

The game of tic-tac-toe is considered a very simple game because it is easy to enumerate all possible board configuration (< 9!). In fact, because numerous configurations symmetric or reflections of other configuration, there are only 765 board distinct configurations. As result, it is easy to define a set of conditional rules that produce a win or a draw.

We will keep our solution very simple. Your game should be designed to allow a human player to compete against a computer player.

Your solution should include the following classes:

1. The Board class to maintain the status of the game (i.e. locations of Xs and Os) along with suitable methods to update the board status and determine board configuration is a win for X, win for O, or a draw.

2. The Computer Player class to generate choices for placement of next O based on the current status of the board.

3. The Score Keeper class to record the number of times each player, human and computer, win.

4. A graphical user interface constructed using JavaFX to provide a visual representation of the board, a display of the number of wins and losses for each player, and suitable mouse actions to support the human players selection of where to place Xs and the computer to respond by placing an O.

To keep the game simple, always allow the user to play X and go first. The computer player will play O and respond to the human players choices. Design the computer player to make a random choice of where to place the next O among the open cells.

You are free to design your GUI to either draw Xs and Os, use a grid of button, use a table or any other suitable visual representation of the board. Your GUI should always display the score (human and computer) and provide a message when the human wins, loses or draws. After each game ends, your solution should reset the board to play another game. The user can terminate the series of games by closing the GUI.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Records And Database Management

Authors: Jeffrey R Stewart Ed D, Judith S Greene, Judith A Hickey

4th Edition

0070614741, 9780070614741

More Books

Students also viewed these Databases questions