Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 48

TIC TAC TOE (ANDROID APPLICATION)

A Mini Project Report


Submitted in Partial Fulfillment for the Award of
BACHELOR OF TECHNOLOGY
IN
COMPUTER SCIENCE & ENGINEERING
By
VIKRAM PAREEK (16RA1A0553)
VARUN (16RA1A0552)

To

Kommuri Pratap Reddy Institute of Technology


Adjacent To NTPC Power Grid, Near Singapore Town Ship, Ghanpur, Ghatkesar,
Telangana 506345
Nov, 2018

1
(Approved by AICTE, New Delhi and affiliated to JNTU, Hyderabad)
(Sponsored by K.P.R Educational Society, Hyderabad)
Ghanpur(V), Ghatkesar(M), Medchal(Dist.) – 500088

CERTIFICATE

Certified that this is the bonafide record of project work done by


Mr. VIKRAM PAREEK and Mr. VARUN Bearing Roll No
16RA1A0553 and 16RA1A0552 respectively during 3rd year 1st
semester of B.Tech on the name of a mini project named
“TIC TAC TOE”.

FACULTY IN-CHARGE EXTERNAL EXAMINER HEAD OF THE DEPT.

2
Acknowledgement

The satisfaction that accompanies the successful completion of this project would be in complete
without the mention of the people who made it possible, without whose constant guidance and
encouragement would have made efforts go in vain. I consider myself privileged to express
gratitude and respect towards all those who guided us through the completion of this project.

I convey thanks to my project guide Mr. R. Krishna Nayak, Asst.Prof. of Computer Science
and Engineering Department for providing encouragement, constant support and guidance which
was of a great help to complete this project successfully.

Last but not the least, we wish to thank our parents for financing our studies in this college as
well as for constantly encouraging us to learn engineering. Their personal sacrifice in providing
this opportunity to learn engineering is gratefully acknowledged.

3
ABSTRACT

ABOUT:-
This project focuses on developing the evergreen paper pencil game “TIC TAC TOE” as a Mobile
based Game on Android platform. The basic idea is to make an offline game wherein two people can
play it on a single device. This game requires two players, one of them will play move ‘X’ and the
other, move ‘O’. For a player to win the game one must align their respective moves either in a
horizontal, vertical or diagonal orientation. Once the player gets the alignment a popup will be
displayed “PLAYER 1 (or) 2 WINS” and the game is done .This application would prove to be a
lightweight game which enables it to run on most of devices (smartphones). People of all age groups
will enjoy this game as it is simple, involving and a perfect way to pass time when you feel bored.

TOOL USED (ANDROID STUDIO):-


Since the project is an Android based Application hence I preferred to develop it on “ANDROID
STUDIO” which certainly is one of the best tool for making applications. Its user friendly design
makes App development fun and interesting, also it has list of widgets that can be dragged and dropped
onto the workspace .The programming area helps us to link the work to be done by these widgets
(Button clicked, scroll down etc.) when an event occurs.

PROGRAMMING LANGUAGE USED:-

This project is entirely based on “JAVA” programming, which surely is a good choice for developing such
lightweight Android Applications. The key features such as object oriented, platform independent,
interpreted and multithreaded makes it a powerful plus attractive choice.

4
List of Figures

Figure 1. DFD Modeling of Game 2


Figure 2. Goal And Vision 3
Figure 3. Sequence Diagram 6
SCREENSHOTS GUI 7-10
TESTING 37

5
Table of Contents
1. INTRODUCTION ........................................................................................................ 1
1.1. Purpose ............................................................................................................. 1
1.2. System Overview ............................................................................................. 1
1.3. Description ....................................................................................................... 1
1.4. DFD Modeling ................................................................................................ 2
1.5. Goal & Vision .................................................................................................. 3
2. REQUIREMENTS SPECIFICATIONS ...................................................................... 4
2.1. User Characteristics ......................................................................................... 4
2.2. Functional Requirements ................................................................................. 4
2.3. Non-Functional Requirements ......................................................................... 5
2.4. Dependencies ................................................................................................... 5
2.5. Performance Requirements .............................................................................. 5
2.6. Hardware Requirements................................................................................... 5
2.7. Constraints and Assumptions ........................................................................... 5
3. DESIGN ....................................................................................................................... 6
3.1. Sequence Diagram .......................................................................................... 6
3.2. GUI Design Front end ................................................................................... 7
4. CODING ..................................................................................................................... 10
5. TESTING .................................................................................................................... 37
6. FUTURE WORK ........................................................................................................ 39
7. CONCLUSION ........................................................................................................... 40
8. REFERENCE S ........................................................................................................ 41

6
INTRODUCTION:

1.1 PURPOSE:

This document is meant to delineate the features of TIC TAC TOE, so as to serve as a guide to the
developers on one hand and a software validation document for the prospective client on the other. TIC
TAC TOE here is application version of the evergreen pen/pencil paper game. This game isn’t complex
and people of all age groups will enjoy this game as it is simple, involving and a perfect way to pass time
when you feel bored.

1.2 OVERVIEW:

This Application would add a new dimension to the previously played game as it would be played on a
smartphone and will also save paper (eco-friendly option!!).

1.3 DESCRIPTION:
This game requires two players, one of them will play move ‘X’ and the other, move ‘O’. For a player to
win the game one must align their respective moves either in a horizontal, vertical or diagonal orientation.
Once the player gets the alignment a popup will be displayed “PLAYER 1 (or) 2 WINS” and the game is
done .This application would prove to be a lightweight game which enables it to run on most of devices
(smartphones).

1
1.4. DFD Modeling
As apparent from the DFD model of problem given on next page, Data-Tag takes
a textual document as input. Data-Tagger application uses content of Wikipedia
Pages fetched from Wikipedia Database via Wikipedia API. Tagged document
along with summary of tags is the output of the system.

Figure 1. DFD of the game

2
1.5. GOAL & VISION
The main motto of this project is to bring in the application version of the evergreen “PAPER PENCIL
TIC TAC TOE” game.

PAPER to SMARTPHONE

3
2. REQUIREMENTS SPECIFICATION

2.1 USER CHARACTERISTICS

The users can interact with the application through an android smart device (preferably a
smartphone).To use the application all you have to do is install the APK file of it, once that is done
you can enjoy playing the game with your opponent.

2.2 FUNCTIONAL REQUIREMENTS:

1. Displaying a 3x3 grid: This grid is required to play the Tic-Tac-Toe game. It is on this
grid that the two players take turns marking the spaces as X and O.

2. Alternating between X and O Players: This game requires two players, one playing as
X and one playing as O (with X usually starting). To ensure that a player doesn’t play
twice, switching between them is required.

3. Determining the Winner of the Game: Once a player wins the game, the message
should be displayed which player won. If no one won the game, then it is a tie.

4. Displaying Score Details: There must be 2 columns for maintaining the scores. One for
each player and one for the games which were a draw.

6. Providing Option to Play Again: The game must provide an option to either play again
or to exit the game.

2.3 NON FUNCTIONAL REQUIREMENTS:

1. Responsiveness: The game application must respond quickly to the players and changing
environment.

2. Usability: The game application must be easy to use so that even the new players can adapt
easily.
3. Reliability: Ability to retrieve the scores even after the game application crashes.
4. Portability: The application is purely developed on JAVA using the tool Android Studio.Hence
this application can run on any platform.

5. Robustness: The application must be robust to allow the scope of making mistakes by the
players.

4
2.4 DEPENDENCIES
The project is an Android Application developed using JAVA programming language in
Android Studio.
Various XML files (used to provide layout to the interfacing in the application ) are include as
well.

2.5 PERFORMANCE REQUIREMENTS:


This application is lightweight and uses minimal amount of system (device) resources. Hence the
performance requirements are negligible.

2.6 HARDWARE REQUIREMENTS:

To access this application, one needs an Android Device (which is at minimal level
running on 4.4.4 i.e. KITKAT).

Apart from this the device must support audio compatibility for the sounds generated
during the gameplay.

2.7 Constraints & Assumptions:


The players must enter their respective names in the naming activity with a limit of
maximum 10 characters. One cannot proceed to the gaming zone unless the valid input is
provided. If you provide an input that exceeds the limit of 10 characters you will get a pop
up displayed.

5
3. DESIGN
3.1 SEQUENCE DIAGRAM:-

The above sequence diagram depicts the interaction of the user with the
application and the sequence in which the application responds to the
inputs provide by the players.

6
3.1 GUI DESIGN FOR FRONT-END

7
8
9
10
4. CODING:

JAVA FILES:
Mainactivity.java:-
package app.tictactoe;
import android.content.Intent;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
private ImageView imageView1;
private TextView textView1;
private Button strt;
private Button abt;
private Button ext;
private Intent intent = new Intent();
private Intent play = new Intent();
private AlertDialog.Builder exit;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initialize();
}
private void initialize() {
imageView1 = (ImageView) findViewById(R.id.imageView1);
textView1 = (TextView) findViewById(R.id.textView1);
11
strt = (Button) findViewById(R.id.strt);
abt = (Button) findViewById(R.id.abt);
ext = (Button) findViewById(R.id.exit);
exit = new AlertDialog.Builder(this);
abt.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
intent.setClass(getApplicationContext(), about.class);
startActivity(intent);
}
});
strt.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
play.setClass(getApplicationContext(),roundof.class);
startActivity(play);
}
});
ext.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
}
}
About.java:-
package app.tictactoe;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;

12
import android.widget.ImageView;
import android.widget.TextView;
public class about extends AppCompatActivity {
private TextView textView2;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.about);
initialize();
initializeLogic();
}
private void initialize() {
textView2 = (TextView) findViewById(R.id.textView2);
}
public void initializeLogic(){
}
}
Roundof.java:-
package app.tictactoe;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
import android.widget.Toast;
public class roundof extends AppCompatActivity {
private TextView nogame;
private RadioGroup rgroup;
private RadioButton sgame;

13
private RadioButton fgame;
private RadioButton segame;
private Button submit;
int v1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.round);
initialize();
}
public void initialize(){
nogame = (TextView) findViewById(R.id.nogame);
rgroup = (RadioGroup) findViewById(R.id.rgroup);
sgame = (RadioButton) findViewById(R.id.sgame);
fgame = (RadioButton) findViewById(R.id.fgame);
segame = (RadioButton) findViewById(R.id.segame);
submit = (Button) findViewById(R.id.submit);
submit.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View _v){
if(rgroup.getCheckedRadioButtonId()==-1){
Toast.makeText(getApplicationContext(),
"PLEASE SELECT AN OPTION", Toast.LENGTH_LONG).show();
}
else{
if(sgame.isChecked()){
Intent myint = new Intent(roundof.this , name.class);
myint.putExtra("val1",1);
startActivity(myint);
}

else if(fgame.isChecked()){

14
Intent myint = new Intent(roundof.this , name.class);
myint.putExtra("val2",5);
startActivity(myint);
}
else{
Intent myint = new Intent(roundof.this , name.class);
myint.putExtra("val3",7);
startActivity(myint);
}
}
}
} );
}
}
Name.java:-
package app.tictactoe;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
public class name extends AppCompatActivity {
private EditText name1;
private EditText name2;
String str1 , str2 ;
private TextView enterview;
private Button btnname;

15
private Intent strt = new Intent();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.pname);
initialize();
}
public void initialize() {
name1 = (EditText) findViewById(R.id.name1);
name2 = (EditText) findViewById(R.id.name2);
enterview = (TextView) findViewById(R.id.enterview);
btnname = (Button) findViewById(R.id.btnname);
btnname.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View _v) {
strt.setClass(getApplicationContext() , game.class);
if(name1.length()>10 || name2.length()>10){
Toast.makeText(getApplicationContext(),
"NAME LENGTH EXCEEDS 10!!", Toast.LENGTH_LONG).show();
}
else if(name1.length()==0 || name2.length()==0 ){
Toast.makeText(getApplicationContext(),
"PLEASE ENTER THE NAME!!", Toast.LENGTH_LONG).show();
}
else
{
strt.putExtra("name_one", name1.getText().toString());
strt.putExtra("name_two", name2.getText().toString());
startActivity(strt);

16
}
}
});
}
}
Game.java:-
package app.tictactoe;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import org.w3c.dom.Text;
import java.util.Timer;
import java.util.TimerTask;
public class game extends AppCompatActivity {
private TextView p1;
private TextView scorex;
private TextView scoreo;
private TextView p2;
private TextView txtX;
private TextView txtO;
private Button cell1;
private Button cell2;
private Button cell3;
17
private Button cell4;
private Button cell5;
private Button cell6;
private Button cell7;
private Button cell8;
private Button cell9;
private double t=0;
private double g1=0;
private double g2=0;
private double ct1=0;
private double ct2=0;
private double ct3=0;
private double ct4=0;
private double ct5=0;
private double ct6=0;
private double ct7=0;
private double ct8=0;
private double ct9=0;
private int i=0 , j=0;
private Timer _timer = new Timer();
private Intent newint = new Intent();
private AlertDialog.Builder Win;
private TimerTask Time;
String text1, text2;
textset();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.demo);
initializeLogic();
18
p1 = (TextView) findViewById(R.id.p1);
p2 = (TextView) findViewById(R.id.p2);
scorex = (TextView) findViewById(R.id.scorex);
scoreo = (TextView) findViewById(R.id.scoreo);
txtX = (TextView) findViewById(R.id.txtX);
txtO = (TextView) findViewById(R.id.txtO);
cell1 = (Button) findViewById(R.id.cell1);
cell2 = (Button) findViewById(R.id.cell2);
cell3 = (Button) findViewById(R.id.cell3);
cell4 = (Button) findViewById(R.id.cell4);
cell5 = (Button) findViewById(R.id.cell5);
cell6 = (Button) findViewById(R.id.cell6);
cell7 = (Button) findViewById(R.id.cell7);
cell8 = (Button) findViewById(R.id.cell8);
cell9 = (Button) findViewById(R.id.cell9);
Win = new AlertDialog.Builder(this);
cell1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View _v) {
if (ct1 == 1) {
if (t == 1) {
cell1.setText("X");
cell1.setBackgroundColor(0xFFF44336);
t--;
} else {
cell1.setText("O");
cell1.setBackgroundColor(0xFF2196F3);
t++;
}
ct1--;
19
t1 = 1;
} else {
Toast.makeText(getApplicationContext(),
"ALREADY PLAYED", Toast.LENGTH_LONG).show();
}
if ((cell1.getText().toString().equals("X") &&
cell2.getText().toString().equals("X")) && cell3.getText().toString().equals("X")) {
i++;
cell1.setText("*");
cell2.setText("*");
cell3.setText("*");
scorex.setText(""+i);
Toast.makeText(getApplicationContext(),
p1.getText() + " WINS", Toast.LENGTH_LONG).show();
Win.setTitle(p1.getText()+" YOU WIN!!");
Win.setMessage("WANT TO PLAY NEW GAME?");
Win.setPositiveButton("YES", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface _dialog, int _which) {
newint.setClass(getApplicationContext(), game.class);
newint = getIntent();
finish();
startActivity(newint);
}
});
Win.setNegativeButton("NO", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface _dialog, int _which) {
finish();
}
20
});
Win.setCancelable(false);
Time = new TimerTask() {
@Override
public void run() {
runOnUiThread(new Runnable() {
@Override
public void run() {
Win.create().show();
}
});
}
};
_timer.schedule(Time, (int) (1500));
} else {
if ((cell1.getText().toString().equals("X") &&
cell5.getText().toString().equals("X")) && cell9.getText().toString().equals("X")) {
i++;
cell1.setText("*");
cell5.setText("*");
cell9.setText("*");
scorex.setText(""+i);
Toast.makeText(getApplicationContext(),
p1.getText() + " WINS", Toast.LENGTH_LONG).show();
Win.setTitle(p1.getText()+" YOU WIN!!");
Win.setMessage("WANT TO PLAY NEW GAME?");
Win.setPositiveButton("YES", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface _dialog, int _which) {
newint.setClass(getApplicationContext(), game.class);
21
newint = getIntent();
finish();
startActivity(newint);
}
});
Win.setNegativeButton("NO", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface _dialog, int _which) {
finish();
}
});
Win.setCancelable(false);
Time = new TimerTask() {
@Override
public void run() {
runOnUiThread(new Runnable() {
@Override
public void run() {
Win.create().show();
}
});
}
};
_timer.schedule(Time, (int) (1500));
} else {
if ((cell1.getText().toString().equals("X") &&
cell4.getText().toString().equals("X")) && cell7.getText().toString().equals("X")) {
i++;
cell1.setText("*");

22
cell4.setText("*");
cell7.setText("*");
scorex.setText(""+i);
Toast.makeText(getApplicationContext(),
p1.getText() + " WINS", Toast.LENGTH_LONG).show();
Win.setTitle(p1.getText()+" YOU WIN!!");
Win.setMessage("WANT TO PLAY NEW GAME?");
Win.setPositiveButton("YES", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface _dialog, int _which) {
newint.setClass(getApplicationContext(), game.class);
newint = getIntent();
finish();
startActivity(newint);
}
});
Win.setNegativeButton("NO", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface _dialog, int _which) {
finish();
}
});
Win.setCancelable(false);
Time = new TimerTask() {
@Override
public void run() {
runOnUiThread(new Runnable() {
@Override
public void run() {
Win.create().show();
23
}
});
}
};
_timer.schedule(Time, (int) (1500));
}
}
}
if ((cell1.getText().toString().equals("O") &&
cell2.getText().toString().equals("O")) && cell3.getText().toString().equals("O")) {
j++;
cell1.setText("$");
cell2.setText("$");
cell3.setText("$");
scoreo.setText(""+j);
Toast.makeText(getApplicationContext(),
p2.getText() + " WINS", Toast.LENGTH_LONG).show();
Win.setTitle(p2.getText()+" YOU WIN!!");
Win.setMessage("WANT TO PLAY NEW GAME?");
Win.setPositiveButton("YES", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface _dialog, int _which) {
newint.setClass(getApplicationContext(), game.class);
newint = getIntent();
finish();
startActivity(newint);
}
});
Win.setNegativeButton("NO", new DialogInterface.OnClickListener() {
@Override
24
public void onClick(DialogInterface _dialog, int _which) {
finish();
}
});
Win.setCancelable(false);
Time = new TimerTask() {
@Override
public void run() {
runOnUiThread(new Runnable() {
@Override
public void run() {
Win.create().show();
}
});
}
};
_timer.schedule(Time, (int) (1500));
} else {
if ((cell1.getText().toString().equals("O") &&
cell5.getText().toString().equals("O")) && cell9.getText().toString().equals("O")) {
j++;
cell1.setText("$");
cell5.setText("$");
cell9.setText("$");
scoreo.setText(""+j);
Toast.makeText(getApplicationContext(),
p2.getText() + " WINS", Toast.LENGTH_LONG).show();
Win.setTitle(p2.getText()+" YOU WIN!!");
Win.setMessage("WANT TO PLAY NEW GAME?");
Win.setPositiveButton("YES", new DialogInterface.OnClickListener() {
25
@Override
public void onClick(DialogInterface _dialog, int _which) {
newint.setClass(getApplicationContext(), game.class);
newint = getIntent();
finish();
startActivity(newint);
}
});
Win.setNegativeButton("NO", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface _dialog, int _which) {
finish();
}
});
Win.setCancelable(false);
Time = new TimerTask() {
@Override
public void run() {
runOnUiThread(new Runnable() {
@Override
public void run() {
Win.create().show();
}
});
}
};
_timer.schedule(Time, (int) (1500));
} else {
if ((cell1.getText().toString().equals("O") &&
cell4.getText().toString().equals("O")) && cell7.getText().toString().equals("O")) {
26
j++;
cell1.setText("$");
cell4.setText("$");
cell7.setText("$");
scoreo.setText(""+j);
Toast.makeText(getApplicationContext(),
p2.getText() + " WINS", Toast.LENGTH_LONG).show();
Win.setTitle(p2.getText()+" YOU WIN!!");
Win.setMessage("WANT TO PLAY NEW GAME?");
Win.setPositiveButton("YES", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface _dialog, int _which) {
newint.setClass(getApplicationContext(), game.class);
newint = getIntent();
finish();
startActivity(newint);
}
});
Win.setNegativeButton("NO", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface _dialog, int _which) {
finish();
}
});
Win.setCancelable(false);
Time = new TimerTask() {
@Override
public void run() {
runOnUiThread(new Runnable() {
@Override
27
public void run() {
Win.create().show();
}
});
}
};
_timer.schedule(Time, (int) (1500));
}
}
}
if ((t1 == 1) && (t1 == t2) && (t1 == t3) && (t1 == t4) && (t1 == t5) && (t1
== t6) && (t1 == t7) && (t1 == t8) && (t1 == t9)) {
Toast.makeText(getApplicationContext(),
"IT'S A TIE", Toast.LENGTH_LONG).show();
Win.setTitle("TIE!!");
Win.setMessage("WANT TO PLAY NEW GAME?");
Win.setPositiveButton("YES", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface _dialog, int _which) {
newint.setClass(getApplicationContext(), game.class);
newint = getIntent();
finish();
startActivity(newint);
}
});
Win.setNegativeButton("NO", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface _dialog, int _which) {
finish();
}
28
});
Win.setCancelable(false);
Time = new TimerTask() {
@Override
public void run() {
runOnUiThread(new Runnable() {
@Override
public void run() {
Win.create().show();
}
});
}
};
_timer.schedule(Time, (int) (1500));
}
}
});
//SIMILARLY FOR THE REST OF CELLS
private void textset(){
Intent intent = getIntent();
text1 = intent.getStringExtra("name_one");
text2 = intent.getStringExtra("name_two");
p1.setText(text1);
p2.setText(text2);
int val = intent.getIntExtra("val1",1);
}
private void initializeLogic(){
t=1;
ct1=1;
ct2=1;
29
ct3=1;
ct4=1;
ct5=1;
ct6=1;
ct7=1;
ct8=1;
ct9=1;
}
@Override
public void onBackPressed(){
finish();
}
}

LAYOUT FILES:
Activity_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="app.tictactoe.MainActivity">
<ImageView
android:id="@+id/imageView1"
android:layout_width="441dp"
android:layout_height="586dp"
android:layout_marginBottom="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"

30
android:layout_marginTop="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.493"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.34"
app:srcCompat="?attr/actionModeSplitBackground" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="16dp"
android:text="TIC TAC TOE"
android:textColor="@android:color/holo_orange_dark"
android:textSize="28sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0" />
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="8dp"

31
android:layout_marginRight="8dp"
android:layout_marginTop="8dp"
android:text="BY VIKRAM PAREEK"
android:textColor="@android:color/holo_red_dark"
android:textSize="25sp"
android:textStyle="bold|italic"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.223" />
<Button
android:id="@+id/strt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="8dp"
android:backgroundTint="@android:color/holo_blue_bright"
android:text="START"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.078"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.767" />
<Button
android:id="@+id/abt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"

32
android:layout_marginBottom="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="8dp"
android:backgroundTint="@android:color/holo_blue_bright"
android:text="ABOUT"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.767" />
<Button
android:id="@+id/exit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="107dp"
android:layout_marginRight="8dp"
android:backgroundTint="@android:color/holo_blue_bright"
android:text="EXIT"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.85"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="8dp"
app:layout_constraintVertical_bias="0.767" />
</android.support.constraint.ConstraintLayout>

33
About.xml:-
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="8dp"
android:text='THIS IS THE APPLICATION VERSION OF THE EVERGREEN
PAPER PENCIL GAME "TIC TAC TOE!! IT
IS A 2 PLAYER GAME (PLAYER1:-X AND PLAYER2:-O) WHEREIN ONE CAN WIN
ONLY BY ALIGNING THEIR MOVES IN EITHER HORIZONTAL,VERTICAL OR
DIAGONAL ORIENTATIONS.'
android:textSize="18sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.017"
tools:layout_constraintLeft_creator="1"
tools:layout_constraintTop_creator="1" />
34
</android.support.constraint.ConstraintLayout>
Pname.xml:-
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/enterview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="8dp"
android:text="ENTER PLAYER NAMES :- ( MAX LENGTH 10 CHARACTERS )"
android:textAlignment="center"
android:textColor="@android:color/black"
android:textSize="20sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.036" />
<Button
android:id="@+id/btnname"
android:layout_width="wrap_content"
35
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="8dp"
android:text="LETS TIC TAC TOE"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.553"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.885"
android:onClick="sendmessage"/>
<EditText
android:id="@+id/name1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="8dp"
android:ems="10"
android:inputType="textPersonName"
android:hint="PLAYER 1"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.503"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
36
app:layout_constraintVertical_bias="0.265" />
<EditText
android:id="@+id/name2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="8dp"
android:ems="10"
android:hint="PLAYER 2"
android:inputType="textPersonName"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout

37
4 TESTING:-
4.1 Types:
 Usability testing– To make sure that the mobile app is easy to use and provides a satisfactory user
experience to the customers
 Compatibility testing– Testing of the application in different mobiles devices, browsers, screen
sizes and OS versions according to the requirements.
 Interface testing– Testing of menu options, buttons, bookmarks, history, settings, and navigation
flow of the application.
 Services testing– Testing the services of the application online and offline.
 Low-level resource testing: Testing of memory usage, auto-deletion of temporary files, local
database growing issues known as low-level resource testing.
 Performance testing– Testing the performance of the application by changing the connection from
2G, 3G to WIFI, sharing the documents, battery consumption, etc.
 Operational testing– Testing of backups and recovery plan if a battery goes down, or data loss
while upgrading the application from a store.
 Installation tests– Validation of the application by installing /uninstalling it on the devices.
 Security Testing– Testing an application to validate if the information system protects data or not.

37
4.2 Test Cases:-
In addition to functionality based test cases, Mobile application testing requires special test cases
which should cover following scenarios.

 Battery usage– It’s important to keep a track of battery consumption while running
application on the mobile devices.
 The speed of the application- the response time on different devices, with different
memory parameters, with different network types etc.
 Data requirements – For installation as well as to verify if the user with the limited data
plan will able to download it.
 Memory requirement– again, to download, install and run
 The functionality of the application– make sure application is not crashing due to network
failure or anything else.

38
5 FUTURE WORK:-
Some of the possible amendments and improvements in this application are:
● Adding an A.I opponent.
● Adding a timer.
● Other minor changes.

Adding an A.I opponent is the single player version of the game wherein the player faces the
software (commonly referred to as computer) instead of facing the other human. Here the
Software will consist of all the possible moves in the programming code logic.

Adding a Timer would make the game more fun and interesting as players must check in their
moves before the timer passes by.
Other minor changes include the changes in the layouts of the gaming zone along with introduction to
sound effects in the application.

Also I would look forward to make it a multiplayer online game version along with a database attached to
it to store the results.

39
6 CONCLUSION:-

The basic idea is to make an offline game wherein two people can play it on a single device.
This game requires two players, one of them will play move ‘X’ and the other, move ‘O’. For a
player to win the game one must align their respective moves either in a horizontal, vertical or
diagonal orientation. Once the player gets the alignment a popup will be displayed “PLAYER 1
(or) 2 WINS” and the game is done .This application would prove to be a lightweight game
which enables it to run on most of devices (smartphones). People of all age groups will enjoy
this game as it is simple, involving and a perfect way to pass time when you feel bored.

40
7 REFERENCES
Websites and videos:
● http://androiddevelopers.com
● http://en.wikipedia.org
● Youtube videos on Android app development.

Textbooks:
 Java : A complete Reference.
 Software Engineering (PRESSMAN & IAN SOMIRVILLE).

41

You might also like