Click here to Skip to main content
15,919,613 members

Comments by Jainam Patel (Top 10 by date)

Jainam Patel 19-May-15 21:26pm View    
import java.util.Scanner;

public class TicTacToeOffical2{

public static Scanner in = new Scanner(System.in);

public static int Introduction(){


System.out.println("Hey");
System.out.println("Today, you will play the game of Tic Tac Toe");
System.out.println("So, let me go over few rules");
System.out.println("Rule #1: This is how the Tic Tac Toe board will look like. ");

try {
Thread.sleep(1500); //Waits 1.5 Seconds
}catch (Exception e) {
System.out.println("Error");
}


System.out.println(" | | ");
System.out.println(" 0 | 1 | 2 ");
System.out.println(" | | ");
System.out.println(" -------------------------------");
System.out.println(" | | ");
System.out.println(" 3 | 4 | 5 ");
System.out.println(" | | ");
System.out.println(" -------------------------------");
System.out.println(" | | ");
System.out.println(" 6 | 7 | 8 ");
System.out.println(" | | ");


try {
Thread.sleep(1500);
}catch (Exception e) { //Waits 1.5 Seconds
System.out.println("Error");
}

System.out.println("Rule #2: Choose a number to place your variable X or O");
System.out.println("Lets say that you choose to be X and you choose the number 4");
System.out.println("So now, the number 4 will be replaced with X");

System.out.println(" | | ");
System.out.println(" 0 | 1 | 2 ");
System.out.println(" | | ");
System.out.println(" -------------------------------");
System.out.println(" | | ");
System.out.println(" 3 | X | 5 ");
System.out.println(" | | ");
System.out.println(" -------------------------------");
System.out.println(" | | ");
System.out.println(" 6 | 7 | 8 ");
System.out.println(" | | ");

try {
Thread.sleep(2000);
}catch (Exception e) { //Waits 1.5 Seconds
System.out.println("Error");
}

System.out.println("Rule #3: To win the game, you have to get 3 X or O in a row ");

System.out.println(" | | ");
System.out.println(" 0 | X | 2 ");
System.out.println(" | | ");
System.out.println(" -------------------------------");
System.out.println(" | | ");
System.out.println(" 3 | X | 5 ");
System.out.println(" | | ");
System.out.println(" -------------------------------");
System.out.println(" | | ");
System.out.println(" 6 | X | 8 ");
System.out.println(" | | ");


try {
Thread.sleep(1500);
}catch (Exception e) { //Waits 1.5 Seconds
System.out.println("Error");
}

System.out.println("So, Would You Like to play Tic Tac Toe?"); // The user will have two options.
System.out.println("Press 1 for yes and 2 for No"); // If the user wants to play, Press 1
int answer = in.nextInt(); // If the user doesn't want to play then press 2
if (answer == 1){
return 2;
}else if (answer == 2){
return 3;
}
return 2;
}


private static int notPlaying(){

System.out.println("So you decided not to play Tic Tac Toe"); // This is the part of the co
Jainam Patel 19-May-15 21:26pm View    
Well Mine Works. It tells who the winner is. But the problem is when we play tic tac toe there will always be a tie. So I am trying to figure it out how I can check if all the 9 turns are used then print tie game.

To make it more clear let me give you an example.

Say you're playerOne and i am player Two.

We are playing Tic Tac Toe.
U enter a number 0. Then I enter 1. Then u enter 2. Then I enter 3 and so on.....

After we've filed all the boxes of tic tac toe and there is no winner then it is a tie game.

So my question to you is: What do I have to do in order to check if all the boxes are full and there is no winner so we can have a Tie Game. '

If you need mine code. Here is the official and full code.

Jainam Patel 18-May-15 22:07pm View    
Look buddy, I don't care who you are but If you want to help me then help and if you don't then why do you even bother to write all this.
Jainam Patel 18-May-15 11:30am View    
Hi, Can you please tell me what I have to do in order to check if the game is tie.

Jainam Patel 16-May-15 20:57pm View    
yesss

Can you please help me with this