2. Problem 2: Horizontal and Vertical Matches Saved 10points possible Reset to Starter Code Problem Description In this

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

2. Problem 2: Horizontal and Vertical Matches Saved 10points possible Reset to Starter Code Problem Description In this

Post by answerhappygod »

2. Problem 2: Horizontal and Vertical Matches
Saved
10points possible
Reset to Starter Code
Problem Description
In this problem, you will write a program that reads datalisting the player’s name and mark on the grid. The program shoulddetermine whether (1) the game is a draw, (2) the game is won byplayer 1, or (3) the game is won by player 2. A game of tic-tac-toeis won by a given player when a player places three marks in a row.The program should determine whether three marks are placed in arow along a horizontal or vertical axis.
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. Theprograms also needs to use a printResults(int) method, that printsthe game results. It will receive an int as a parameter, the valueof the parameter should be -1 if the game is a draw, 1 if P1 won,and 2 if P2 won, and it won't return any value.
Input
You will receive (from the user) the following as input (inorder):
Processing
Examples
Input
Output
P1 A1P2 B2P1 A2P2 B1P1 A3P2 Finish
1 2 0
1 2 0
1 0 0
Game Over - Player 1 Wins
P1 B2P2 A1P1 B1P2 A2P1 C1P2 A3P1 Finish
2 1 1
2 1 0
2 0 0
Game Over - Player 2 Wins
P1 C3P2 A2P1 Finish
0 0 0
2 0 0
0 0 1
Game Over - Draw
Player1 1 Player2 5 Player1 2 Player2 6 Player1 3 Player2 -1
1 1 1
0 2 2
0 0 0
Game Over - Player 1 Wins
Java, use Scanner class
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply