Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I am trying to create a runGameHistory method for my tic-tac-toe java program. Currently it looks like this: However it is producing the incorrect output

I am trying to create a runGameHistory method for my tic-tac-toe java program. Currently it looks like this:

image text in transcribed

However it is producing the incorrect output and it looks like this:

playername (X) vs Computer (O) | | ----------- | | ----------- | | Computer: X | | ----------- | O | ----------- | | playername: X | | ----------- | O | ----------- | | Computer: X | X | O ----------- | O | ----------- | | playername: X | X | O ----------- | O | ----------- | | Computer: X | X | O ----------- X | O | ----------- O | | playername: X | X | O ----------- X | O | ----------- O | | Computer: X | X | O ----------- X | O | ----------- O | | Computer wins!

It is not printing the first turn by playername and some of the other turns are printed multiple times.

It also produces the incorrect output when the second player (the computer) goes first which is shown below:

playername (X) vs Computer (O) | | ----------- | | ----------- | | Computer: | | ----------- | O | ----------- | | playername: X | | ----------- | O | ----------- | | O Computer: X | | ----------- | O | ----------- | | O playername: X | X | O ----------- | O | ----------- | | O Computer: X | X | O ----------- | O | ----------- | | O playername: X | X | O ----------- X | O | O ----------- | | O Computer: X | X | O ----------- X | O | O ----------- | | O playername: X | X | O ----------- X | O | O ----------- | | O playername wins!

Missing one of the turns, returning duplicates of many of the turns, and produces the incorrect winner.

Could you change the method so that it produces the correct output no matter which player goes first.

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

Professional SQL Server 2012 Internals And Troubleshooting

Authors: Christian Bolton, Justin Langford

1st Edition

1118177657, 9781118177655

More Books

Students also viewed these Databases questions