Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Help with Java Gomoku program So I am trying to write a program that plays a basic Gomoku game. I am to the point where

Help with Java Gomoku program

image text in transcribedSo I am trying to write a program that plays a basic Gomoku game. I am to the point where I have printed the initial map and gotten player 1's first move. I've attached a screenshot of what I have so far and pasted the code below.

I am stuck though in figuring out how to alternate between player one and player two. I'd like it to ask the same questions, but say "Player 2's turn!" and put an O instead of an X for player 2.

I understand there will be more to it in order to finish it, but I'd just like to get this next step and understand it before moving on. Thanks!

import java.util.Scanner;

public class Gomoku { public static void main (String[] args) { Scanner input = new Scanner(System.in);

char[][] map = new char [19][19];

//fill game with dots for (int i = 0; i

printMap(map);

System.out.println("Player 1's turn!"); System.out.print("Enter row: "); int row = input.nextInt();

System.out.print("Enter column: "); int column = input.nextInt();

int place [][] = new int [row][column];

map[row][column] = 'X'; printMap (map);

}

public static void printMap (char[][] map) { for (int i = 0; i

}

Fle Edt Searrh Teals e Conf gure Window Hep ox inE 1-0 1ap.lengch: 1 Syazem.out print("Enter zoi1 in: ooluninput.next Inz ap.length:+) loal Gutpur Search Results -Tool Output! O lype here to search

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

Students also viewed these Databases questions

Question

sustainability of devices in HUMAN COMPUTER INTERACTION

Answered: 1 week ago

Question

What is topology? Explain with examples

Answered: 1 week ago

Question

Compare levels of resolution in conflict outcomes?

Answered: 1 week ago

Question

Strategies for Managing Conflict Conflict Outcomes?

Answered: 1 week ago