I should have a codecalled 5 in a row It\'s like tictactoe but you need 5 to win
ID: 3617702 • Letter: I
Question
I should have a codecalled 5 in a rowIt's like tictactoe but you need 5 to win
and it is multi-playered(user should say how manyplayers)
your task is to make this program to be able
to determine the winner (as of now this does not)..thanks!
import java.io.*;
public class untitled {
public static void main (String[] args)throws Exception
{
BufferedReader keyIn = new BufferedReader(newInputStreamReader(System.in));
char[][] B =new char[10][10]; // B is forBoard
boolean win= false;
intplayers;
System.out.print("How many players are there? ");
players =Integer.parseInt(keyIn.readLine());
char[] c =new char[players];
for(inti=0;i<players;i++)
{System.out.print("enter symbol for player "+(i+1));
c[i]=keyIn.readLine().charAt(0);
}
System.out.println(" ");
System.out.println(" ~~~~~~~~ 5 IN A ROW GAME~~~~~~~~");
System.out.println(" ");
//initializeour board
for(int i=0;i<10; i++)
for(int j=0; j<10; j++)
B[i][j] = '-';
//displayour board
for (inti=0; i<10; i++)
{
for(int j=0; j<10; j++)
System.out.print(" " +B[i][j]);
System.out.println();
}
for(intt=0; (t<9) || !win ; t++)
{
System.out.println("Player "+(t%players+1));
System.out.print("row =");
int row = Integer.parseInt(keyIn.readLine());
System.out.print("column = ");
int col = Integer.parseInt(keyIn.readLine());
B[row][col] = c[t%players]; //alternates betweenplayers
//display board
for(int i=0; i<10; i++)
{
for (int j=0;j<10;j++)
System.out.print(" " + B[i][j]);
System.out.println();
}
}
}
} I should have a codecalled 5 in a row
It's like tictactoe but you need 5 to win
and it is multi-playered(user should say how manyplayers)
your task is to make this program to be able
to determine the winner (as of now this does not)..thanks!
your task is to make this program to be able
to determine the winner (as of now this does not)..thanks!
Explanation / Answer
x.Xlor="red">please rate - thanks import java.io.*; public class untitled { public static void main (String[] args) throws Exception { BufferedReader keyIn = new BufferedReader(new InputStreamReader(System.in)); char[][] B = new char[5][5]; // B is for Board boolean win = false; int players; System.out.print("How many players are there? "); players = Integer.parseInt(keyIn.readLine()); char[] c = new char[players]; for(int i=0;iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.