Problem Description
A tic-tac-toe grid involves two players each taking a turn toplace the marks X and O in one of the nine spaces in the grid, asshown below:
In this problem, you will write a program that reads datalisting the player’s name and mark location on the grid, asindicated on this board. The input should be in the format ofletter number, e.g., A1, B3, etc. The program should display asoutput the board, the mark of each player (either player 1 or 2;and 0 for an empty grid).
The program needs to also use a method calledtransformInputToIndex(String), that gets the user input as aparameter, e.g., A1, and returns a cell number, e.g., 1.
Input
You will receive (from the user) the following as input (inorder):
Processing
Examples
Input
Output
P1 A1
P2 B2
P1 A2
P2 B1
P1 A3
P2 Finish
1 2 0
1 2 0
1 0 0
P1 B2
P2 A1
P1 B1
P2 A2
P1 C1
P2 A3
P1 Finish
2 1 1
2 1 0
2 0 0
P1 C3
P2 A2
P1 Finish
0 0 0
2 0 0
0 0 1
Solve in Java
Use Scanner class
Problem Description A tic-tac-toe grid involves two players each taking a turn to place the marks X and O in one of the
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
Problem Description A tic-tac-toe grid involves two players each taking a turn to place the marks X and O in one of the
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!