PROGRAM::
/**
First Run it and then Read the Following.
Give inputs as 11,22,33, or 12,13
it takes input as matrices indexes
if you want to place at 1st position then it is 11
if you want to place at 5th then it is 22
Player-1 will place '@' at where he claims , where Player-2 do '#'
*/
import java.util.*;
public class Tick
{
static
{
System.out.println("Do You Want to play the game (y/n)?");
String decision = new Scanner(System.in).nextLine();
if (decision.equals("n") || !decision.equals("y"))
{
System.out.println("Than Q!");
System.exit(0);
}
System.out.println("\t*******Game Rules*******");
System.out.println("\t1.Player has to Claim a Position.");
System.out.println("\t2. Who claims First Horizontally,\n\t Vertically or Diagonally, will be the Winner");
}
public static void printScreen()
{
System.out.println(" 1 2 3");
System.out.println(" +---+---+---+");
System.out.println(" 1 | "+arr[0][0]+" | "+arr[0][1]+" | "+arr[0][2]+" |");
System.out.println(" +---+---+---+");
System.out.println(" 2 | "+arr[1][0]+" | "+arr[1][1]+" | "+arr[1][2]+" |");
System.out.println(" +---+---+---+");
System.out.println(" 3 | "+arr[2][0]+" | "+arr[2][1]+" | "+arr[2][2]+" |");
System.out.println(" +---+---+---+");
}
public static int checkWinner()
{
if (arr[0][0]!="." && ((arr[0][0]==arr[0][1]) && (arr[0][0]==arr[0][2])))
{
if (arr[0][0]=="#")
{
return 2;
}
else return 1;
}
else if (arr[1][0]!="." && ((arr[1][0]==arr[1][1]) && (arr[1][0]==arr[1][2])))
{
if (arr[1][0]=="#")
{
return 2;
}
else return 1;
}
else if (arr[2][0]!="." && (arr[2][0]==arr[2][1]) && (arr[2][0]==arr[2][2]))
{
if (arr[2][0]=="#")
{
return 2;
}return 1;
}
else if (arr[0][0]!="." && (arr[0][0]==arr[1][0]) && (arr[0][0]==arr[2][0]))
{
if (arr[0][0]=="#")
{
return 2;
}return 1;
}
else if (arr[0][1]!="." && ((arr[0][1]==arr[1][1]) && (arr[0][1]==arr[2][1])))
{
if (arr[0][1]=="#")
{
return 2;
}return 1;
}
else if (arr[0][2]!="." && ((arr[0][2]==arr[1][2]) && (arr[0][2]==arr[2][2])))
{
if (arr[0][2]=="#")
{
return 2;
}return 1;
}
// Diag
else if (arr[0][0]!="." && (arr[0][0]==arr[1][1] && arr[0][0]==arr[2][2]))
{
if (arr[0][0]=="#")
{
return 2;
}return 1;
}
else if (arr[0][2]!="." && (arr[0][2]==arr[1][1] && arr[0][2]==arr[2][0]))
{
if (arr[0][0]=="#")
{
return 2;
}return 1;
}
return -1;
}
static String[][] arr=new String[3][3];
public static void initialize()
{
for (int i=0;i<3;i++)
{
for (int j=0;j<3;j++)
{
arr[i][j]=".";
}
}
}
public static void main(String[] args)
{
final int totalPossibleAttempts=9;
initialize();
int i=0;
while (i<totalPossibleAttempts)
{
printScreen();
if (i%2==0)
{
System.out.print("Player-1 turn (@) : ");
int position = getPosition();
if (!isOccupied(position))
{
fillAt(position,"@");
}
else
{
System.out.println("This Position is already Occupied!");
continue;
}
}
else
{
System.out.print("Player-2 turn (#) : ");
int position = getPosition();
if (!isOccupied(position))
{
fillAt(position,"#");
}
else
{
System.out.println("This Position is already Occupied!");
continue;
}
}
if (checkWinner()==2)
{
printScreen();
System.out.println("Player-2 is Winner!");
return;
}
else if (checkWinner()==1)
{
printScreen();
System.out.println("Player-1 is Winner!");
return;
}
i++;
}
printScreen();
int winner = checkWinner();
if (winner==1)
{
System.out.println("Player-1 is winner ");
}
else if (winner==2)
{
System.out.println("Player-2 is winner");
}
else if (winner==-1)
{
System.out.println("No one win");
}
}
public static int getPosition()
{
int n=0;
try
{
n = (new Scanner(System.in)).nextInt();
}catch(Exception e){
System.out.print("Invalid Position select another : ");
return getPosition();
}
if ((n>10 && n<34) && (n%10==1 || n%10==2 || n%10==3))
{
return n;
}
System.out.print("Invalid Position select another : ");
return getPosition();
}
public static boolean isOccupied(int row,int col)
{
if (arr[r][c]==" ")
{
return false;
}
return true;
}
public static void fillAt(int position,String by)
{
if (position==11)
{
arr[0][0]=by;
}else if (position==12)
{
arr[0][1]=by;
}else if (position==13)
{
arr[0][2]=by;
}else if (position==21)
{
arr[1][0]=by;
}else if (position==22)
{
arr[1][1]=by;
}else if (position==23)
{
arr[1][2]=by;
}else if (position==31)
{
arr[2][0]=by;
}else if (position==32)
{
arr[2][1]=by;
}
else if (position==33)
{
arr[2][2]=by;
}
}
}
OUTPUT::

In java language
here is my code so far! i only need help with the extra credit
part
For this project, you will create a Rock, Paper, Scissors
game.
Write a GUI program that allows a user to play Rock, Paper,
Scissors against the computer.
If you’re not familiar with Rock, Paper, Scissors, check out the
Wikipedia page:
http://en.wikipedia.org/wiki/Rock-paper-scissors
This is how the program works:
The user clicks a button to make their move (rock, paper, or
scissors).
The program...
A subtraction game Subtraction games are two-player games in which there is a pile of objects, say coins. There are two players, Alice and Bob, who alternate turns subtracting 4.9. A SUBTRACTION GAME 19 from the pile some number of coins belonging to a set S (the subtraction set). Alice goes first. The first player who is unable to make a legal move loses. For example, suppose the initial pile contains 5 coins, and each player can, on his turn,...
Introduction Write a MIPS program to allow a user to play a simple variation of the game BINGO. Your program should display the following game board and the player wants to choose a location to mark BINGO A position can be marked by entering its column letter (eit B', 'I', 'N' 'G', or CO and row number (either 1, 2, 3, 4, or 5). An 'X' should mark the positions already marked. An underscore, e C 1 should represent unmarked...
Question 3 [10 points] Bob and Doug play a lot of Ping-Pong, but Doug is a much better player, and wins 90% of their games. To make up for this, if Doug wins a game he will spot Bob tive points in their next game. if Doug wins again he will spot Bob ten points the next game, and if he still wins the next game he will spot him ifteen points, and continue to spot hinm ifteen points as...
It's writing a simple rock paper scissors game strictly following the instructions. INSTRUCTIONS: If the user selects 'p': 1. First the program should call a function named getComputerChoice to get the computer's choice in the game. The getComputerChoice function should generate a random number between 1 and 3. If the random number is 1 the computer has chosen Rock, if the random number is 2 the user has chosen Paper, and if the random number is 3 the computer has...
C++ Write a program that plays the rock, paper, scissors game. Rock beats scissors; scissors beats paper; paper beats rock. You must use these specific functions in your program. These are the prototypes: char generateP2toss(); int checkThrow(char, char); void printStatistics(int, int, int, int); void finalStatistics(int, int, int, int); void welcome(); Notes on these functions: generateP2toss() will generate the computer's toss (the computer is player2). It returns either an "r", "p", or "s/" checkThrow(char char) will check the throw by passing...
Write a c++ program that simulates a million of games in craps. I am having a trouble getting to loop a million of times. I am trying to use a const for a million. This is the code so far. #include <iostream> #include <cstdlib>// contains prototypes for functions srand and rand #include <ctime>// contains prototype for function time #include <iomanip> using namespace std; int rollDice(); // rolls dice, calculates and displays sum void printstats(); int totroll = 0, games, point,...
Problem 3. In the game of tennis, the first player to win four points wins the game as long as the winner's total is at least two points more than the opponent. Thus if the game is tied at 3-3(Deuce"), then the game is not decided by the next point, but must go on until one player has two points more than the opponent's score. Assume that the server has a constant probability p of winning each point, independently of...
Question 9 [10 points] Bob and Doug play a lot of Ping-Pong, but Doug is a much better player, and wins 90% of their games. To make up for this, if Doug wins a game he will spot Bob five points in their next game. If Doug wins again he will spot Bob ten points the next game, and if he still wins the next game he will spot him fifteen points, and continue to spot him fifteen points as...
Question 9 [10 points] Bob and Doug play a lot of Ping-Pong, but Doug is a much better player, and wins 70% of their games To make up for this, if Doug wins a game he will spot Bob five points in their next game. If Doug wins again he will spot Bob ten points the next game, and if he still wins the next game he will spot him fifteen points, and continue to spot him fifteen points as...