Question
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:
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started