TEC TAC TOE JAVA
$10-30 USD
Płatność przy odbiorze
Hi
could you write same this cod but on different way ASAP?? 10$
import [login to view URL];
public class Tictactoe {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
//initializing board and update array
char [][]board = new char [3][3];
char [][]update = new char[3][3];
board = printboard();// method to print the initial board and the array is returned to board
insertXO(board); //Inserting X and ) method
//updateboard(update);
//checkwin(update);
}
public static char[][] printboard() // Printing initial board method
{
char [][]board = new char [3][3]; // initializing board.
board [0][0] = '1'; // assinging 1 number of board to 1
board [0][1] = '2';
board [0][2] = '3';
board [1][0] = '4';
board [1][1] = '5';
board [1][2] = '6';
board [2][0] = '7';
board [2][1] = '8';
board [2][2] = '9';
[login to view URL](board[0][0]+" | " + board[0][1]+ " | "+board[0][2]); // printing each row.
[login to view URL]("----------");
[login to view URL](board[1][0]+" | " + board[1][1]+ " | "+board[1][2]);
[login to view URL]("----------");
[login to view URL](board[2][0]+" | " + board[2][1]+ " | "+board[2][2]);
return board;
}
public static void insertXO(char [][] board) // inserting X and O method.
{
int a,b,moves=0; // initializing variables.
Scanner scnr = new Scanner ([login to view URL]);// Declaring Scanner
while(moves<9) // repeating till moves <9
{
//moves++; // incrementing moves
[login to view URL]("PLayer 1 : Enter x");
a = [login to view URL](); // player enters x
switch (a) { // switch statement for x to place the x in correct number.
case 1:
board[0][0]='x';
break;
case 2:
board[0][1]='x';
break;
case 3:
board[0][2]='x';
break;
case 4:
board[1][0]='x';
break;
case 5:
board[1][1]='x';
break;
case 6:
board[1][2]='x';
break;
case 7:
board[2][0]='x';
break;
case 8:
board[2][1]='x';
break;
case 9:
board[2][2]='x';
break;
default:
break;
}
moves++;//incrementing moves for the first player
if(checkwin(board)) // calling the method to check the winner,
{
[login to view URL]("Player 1 You Won"); // If player 1 wins then break the loop
break;
}
if(moves==9) // If the moves equal to 9 then its a tie and break the loop.
{
[login to view URL]("Its a Tie!!");
break;
}
//else
//[login to view URL]("Tie");
//break;
updateboard(board); // calling updateboard method after entering X
[login to view URL]("Player 2: Enter o");
b = [login to view URL](); // Enter the O.
switch (b) { // switch statement for o to place the o in correct number.
case 1:
board[0][0]='o';
break;
case 2:
board[0][1]='o';
break;
case 3:
board[0][2]='o';
break;
case 4:
board[1][0]='o';
break;
case 5:
board[1][1]='o';
break;
case 6:
board[1][2]='o';
break;
case 7:
board[2][0]='o';
break;
case 8:
board[2][1]='o';
break;
case 9:
board[2][2]='o';
break;
default:
break;
}
moves++; ////incrementing moves for the second player
if(checkwin(board)) // calling the method to check the winner,
{
[login to view URL]("Player 2 You Won!!!"); // If player 2 wins then break the loop
break;
}
Numer ID Projektu: #16694537
O projekcie
Przyznany użytkownikowi:
Hello there, Read your project. I can rewrite the code so that you can evade plagiarism. We can discuss details over chat. Looking forward to hear from you. Regards, Zeeshan Ahmed
6 freelancerów złożyło ofertę za $24 w tym projekcie
I am yaj have more than 7 years of experience in java. I have done so many projects. I can solve the Issue.
My speciality its Web Design and Java/JSP/MYSQL Full Stack. I have 4 year experience working as a software developer freelance. Skills: * JAVA * JSP * JSF * MYSQL * HTML * JAVASCRIPT * CSS * .NET * PHP Więcej