Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Must be done in RAPTOR array flowchart. For Project #2 you will be completing Programming Exercise 8.10 - Tic-Tac-Toe Game. This should be a challenging,

Must be done in RAPTOR array flowchart.

For Project #2 you will be completing Programming Exercise 8.10 - Tic-Tac-Toe Game. This should be a challenging, yet fun exercise for you to work on this week. Make sure you allow yourself plenty of time to complete the assignment this week. The full program description is below:

Design a program that allows two players to play a game of tic-tac-toe. One approach would use a two-dimensional String array with three rows and three columns as the game board. Or, you might use a one-dimensional array with 9 elements. Each element of the array should be initialized with a character or string like '*' or "*". Another way to initialize the array would be with numeric characters like "1", "2", "3", etc. This would display the board so the user can choose the number corresponding to the location where they want to place their "X" or "O". The single quotes are used for single characters, the double quotes are used for strings. In this program, it doesn't matter whether you use characters or strings, but you must stay consistent through the entire program or it will not work. The program should run a loop that does the following:

Displays the contents of the board array

Allows player 1 to select a location on the board for an X. The program should ask the user to enter the row and column number (Or enter the cell number if using a 1D array).

Allows player 2 to select a location on the board for an O. The program should ask the user to enter the row and column number (Or enter the cell number if using a 1D array).

Determines whether a player has won or if a tie has occurred. If a player has won, the program should declare that player the winner and end. If a tie has occurred, the program should say so and end.

Player 1 wins when there are three Xs in a row on the game board. Player 2 wins when there are three Os in a row on the game board. The winning Xs or Ox can appear in a row, in a column, or diagonally across the board. A tie occurs when all of the locations on the board are full, but there is no winner. To check for a winner, the easiest approach is to create a series of 8 selection (if) statements that checks for each possible winning combination. Unfortunately, there is not easy approach to use a loop or shorter method for checking for a winner.

To get full credit for this project, make sure you use proper input validation for all user entries (make sure the input selection is valid and the spot is not already in use) and break the program up into functions and modules where appropriate.

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

Step: 3

blur-text-image

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

Database And Expert Systems Applications 24th International Conference Dexa 2013 Prague Czech Republic August 2013 Proceedings Part 1 Lncs 8055

Authors: Hendrik Decker ,Lenka Lhotska ,Sebastian Link ,Josef Basl ,A Min Tjoa

2013 Edition

3642402844, 978-3642402845

More Books

Students also viewed these Databases questions

Question

What is Working Capital ? Explain its types.

Answered: 1 week ago