Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I wanted to know how to place the results of my for loops into a variable. Like in this code I am trying to set

I wanted to know how to place the results of my for loops into a variable. Like in this code I am trying to set index of the row and column from the for loops into the variables rrow and rcol which are outside the for loops. when I print rrow to see if it copied I get 0 as an answer.

public void placeStone(char row,char col,String user) {

// TODO Auto-generated method stub

int rrow=0;

int rcol=0;

char symbol=' ';

if(user.equals("player")) {

symbol='X';

}else if(user.equals("cpu")){

symbol='O';

}

for(int i=0;i

for(int j=0;j

if(board[i][j]==row) {

rrow=j;

}

}

}

for(int i=1;i

for(int j=0;j

if(board[i][j]==row) {

rcol=i;

}

}

//while(!board[i].equals(row)) {

//int tmp=0;

//tmp++;

//rrow=tmp;

//}

}

System.out.println("testing "+rrow);

board[rrow][rcol]=symbol;

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

Excel As Your Database

Authors: Paul Cornell

1st Edition

1590597516, 978-1590597514

More Books

Students also viewed these Databases questions