Professional Documents
Culture Documents
OOPS PROJECT REPORT Sheraz 21
OOPS PROJECT REPORT Sheraz 21
OOPS PROJECT REPORT Sheraz 21
Page ACKNOWLEDGMENT 3
ABSTRACT 3
INTRODUCTION 4
THEORETICAL BACKGROUND 4
METHODOLOGY 4
FLOW CHART 6
CONCLUSION AND RESULT 7
PROJECT CODE 8
PROJECT OUTPUT 13
REFERENCE 14
They have given us the chance to work on this project. They admire our abilities and
increased our knowledge about practical life. They not only gives us there precious
time but also shared there valuable thoughts about the topic. The supervision and
support that they gave truly help the progression and smoothness of the project. The
co-operation is much indeed appreciated.
ABSTRACT
The project title is ‘TICTAC TOE GAME’ In first step we are taking input from
users that which player is starting the game they have two write number between 1
and 2, because we have two players in this game player 1 symbol is ‘x’ and player 2
symbol is ‘o’. user have to decide themselves that who is payer 1 and who is player
2.
If player 1 is starting the game. It is necessary that player 1 must enter number
between 1 to 9 and symbol ‘x’ and if player 2 starting the game. It is necessary that
player 2 must enter number between 1 to 9 and symbol ‘o’. if Player 1 starts the
game and he enter any number between 1 to 9 with symbol ‘x’ the program starts
INTRODUCTION
METHODOLOGY :
Following are the steps that are involved in the project of TIC TAC TOE GAME.
Step no 1:
In first step we are taking input from users that which player is starting the game
they have two write number between 1 and 2, because we have two players in this
game player 1 symbol is ‘x’ and player 2 symbol is ‘o’. user have to decide
themselves that who is payer 1 and who is player 2.
if Player 1 starts the game and he enter any number between 1 to 9 with symbol ‘x’
the program starts working on this and change that number with symbol ‘x’ in
show function we have in our project (in the form of array) after this turn is shifted
towards player 2. And player 2 have to enter number between 1 to 9 accept the
number which is enter once by opponent player before his turn with symbol
‘o’. The program starts working on this and change that number with symbol ‘o’ in
show function we have in our project (in the form of array) after this turn is shifted
towards player 1 and the process done that player 1 done in his 1st turn.
Step no 4:
if Player 2 starts the game and he enter any number between 1 to 9 with
symbol ‘o’ the program starts working on this and change that number with symbol
‘o’ in show function we have in our project (in the form of 2 array) after this turn is
shifted towards player 1. And player 1 have to enter number between 1 to 9 accept
the number which is enter once by opponent player before his turn with symbol
‘x’. The program starts working on this and change that number with symbol ‘x’ in
show function we have in our project (in the form of 2 array) after this turn is
shifted towards player 2 and the same done that player 2 done in his 1st turn.
Step no 5:
Are same with symbol ‘x’ or ‘o’ and similarly until all number between
1 and 9 are filled with symbols ‘x’ or ‘o’.
step no 6:
If any column, any row and any diagonal is match or same with symbol ‘x’ then
the player with symbol ‘x’ that is player 1 won the game. And if any column, any
row and any diagonal is match or same with symbol ‘o’ then player with symbol
‘o’ that is player 2 won the game.
If not any diagonal, any column and row match or same with symbol
‘x’ or ‘o’ means game is draw and no one is the winner. Step
no 8:
User have choice if they want to play the game again they need to press y and if
they have not to play the game again they need to press n then press step no 3 OR
step no 4 repeat itself until any column, any row and any diagonal.
Flow chart:
package tictactoegame;
import java.util.*;
switch (a) {
case 0:
line = board[0] + board[1] + board[2];
break;
case 1:
line = board[3] + board[4] + board[5];
break;
case 2:
line = board[6] + board[7] + board[8];
break;
case 3:
line = board[0] + board[3] + board[6];
break;
case 4:
line = board[1] + board[4] + board[7];
break;
// For O winner
else if (line.equals("OOO")) {
return "O";
}
}
System.out.println(
System.out.println("Welcome to 3x3
Tic Tac Toe.");
printBoard();
System.out.println(
"X will play first. Enter a slot number
to place X in:");
// Exception handling.
// numInput will take input from user
like from 1 to 9.
// If it is not in range from 1 to 9.
// then it will show you an error
"Invalid input."
try {
numInput = in.nextInt();
if (!(numInput > 0 && numInput <=
9)) {
System.out.println(
"Invalid input; re-enter slot
number:");
continue;
}
}
catch (InputMismatchException e) {
if (turn.equals("X")) {
turn = "O";
}
else {
turn = "X";
}
printBoard();
winner = checkWinner();
}
else {
System.out.println(
"Slot already taken; re-enter slot
number:");
}
}
OUTPUT:
Jdk8