15,919,613 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
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
Jainam Patel
12-May-15 7:53am
View
This is the code that I used. But it only asks the user for One time. Please help me.
import java.util.Scanner;
public class TicTacToeArray {
public static void main(String[] args){
Scanner in = new Scanner(System.in);
int [] A1 = {0,1,2};
int [] A2 = {3,4,5};
int [] A3 = {6,7,8};
for (int i = 0; i < 8; i++){
in.nextInt();
}
System.out.println("Player #1: Please enter a number between 0-8");
int playerOne = in.nextInt();
if (playerOne == A1 [0]){
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(" | | ");
}else if (playerOne ==A1 [1]){
System.out.println(" | | ");
System.out.println(" 0 | X | 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(" | | ");
}else if (playerOne ==A1 [2]){
System.out.println(" | | ");
System.out.println(" 0 | 1 | X ");
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(" | | ");
}else if (playerOne ==A2 [0]){
System.out.println(" | | ");
System.out.println(" 0 | 1 | 2 ");
System.out.println(" | | ");
System.out.println(" -------------------------------");
System.out.println(" | | ");
System.out.println(" X | 4 | 5 ");
System.out.println(" | | ");
System.out.println(" -------------------------------");
System.out.println(" | | ");
System.out.println(" 6 | 7 | 8 ");
System.out.println(" | | ");
// And the Rest If statement Goes Here.
Jainam Patel
10-May-15 15:33pm
View
Can you help me with modifying the my original code.
I just don't know how to do it.
It will be great if you can help me modify the original code.
Jainam Patel
10-May-15 15:20pm
View
Deleted
Can you help me with modifying the my original code.
I just don't know how to do it.
It will be great if you can help me modify the original code.
Jainam Patel
10-May-15 15:10pm
View
Is there any that I can modify this thing in My CODE.
I get what you're saying but is there any way that I could do it in my code.
Jainam Patel
10-May-15 14:33pm
View
Thanx for the idea but I want to do something like this.
I ask you for a number between 0-8. You choose a number 5. Then it should print out the tic tac toe board where 5 will be replaced by X Then I ask you again for a number between 0-8. Say you choose 3 It should then show the tic tac toe board where 5 and 3 will be replaced by X
It will be great if you can help with this program
Show More