Skip to content

Commit d417b9d

Browse files
authored
Add files via upload
1 parent 231d57b commit d417b9d

32 files changed

Lines changed: 712 additions & 0 deletions

app/build.gradle

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
plugins {
2+
id 'com.android.application'
3+
}
4+
5+
android {
6+
namespace 'com.enginedroid.tictactoe'
7+
compileSdk 33
8+
9+
defaultConfig {
10+
applicationId "com.enginedroid.tictactoe"
11+
minSdk 24
12+
targetSdk 33
13+
versionCode 1
14+
versionName "1.0"
15+
16+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
17+
}
18+
19+
buildTypes {
20+
release {
21+
minifyEnabled false
22+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
23+
}
24+
}
25+
compileOptions {
26+
sourceCompatibility JavaVersion.VERSION_1_8
27+
targetCompatibility JavaVersion.VERSION_1_8
28+
}
29+
}
30+
31+
dependencies {
32+
33+
implementation 'androidx.appcompat:appcompat:1.6.1'
34+
implementation 'com.google.android.material:material:1.8.0'
35+
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
36+
testImplementation 'junit:junit:4.13.2'
37+
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
38+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
39+
}

app/proguard-rules.pro

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.enginedroid.tictactoe;
2+
3+
import android.content.Context;
4+
5+
import androidx.test.platform.app.InstrumentationRegistry;
6+
import androidx.test.ext.junit.runners.AndroidJUnit4;
7+
8+
import org.junit.Test;
9+
import org.junit.runner.RunWith;
10+
11+
import static org.junit.Assert.*;
12+
13+
/**
14+
* Instrumented test, which will execute on an Android device.
15+
*
16+
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
17+
*/
18+
@RunWith(AndroidJUnit4.class)
19+
public class ExampleInstrumentedTest {
20+
@Test
21+
public void useAppContext() {
22+
// Context of the app under test.
23+
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
24+
assertEquals("com.enginedroid.tictactoe", appContext.getPackageName());
25+
}
26+
}

app/src/main/AndroidManifest.xml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools">
4+
5+
<application
6+
android:allowBackup="true"
7+
android:dataExtractionRules="@xml/data_extraction_rules"
8+
android:fullBackupContent="@xml/backup_rules"
9+
android:icon="@mipmap/ic_launcher"
10+
android:label="@string/app_name"
11+
android:supportsRtl="true"
12+
android:theme="@style/Theme.TicTacToe"
13+
tools:targetApi="31">
14+
<activity
15+
android:name=".LogoActivity"
16+
android:exported="true" >
17+
<intent-filter>
18+
<action android:name="android.intent.action.MAIN" />
19+
20+
<category android:name="android.intent.category.LAUNCHER" />
21+
</intent-filter>
22+
</activity>
23+
<activity
24+
android:name=".MainActivity"
25+
android:exported="true">
26+
</activity>
27+
</application>
28+
29+
</manifest>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.enginedroid.tictactoe;
2+
3+
import androidx.appcompat.app.AppCompatActivity;
4+
5+
import android.content.Intent;
6+
import android.os.Bundle;
7+
import android.os.Handler;
8+
import android.view.animation.Animation;
9+
import android.view.animation.AnimationUtils;
10+
import android.widget.ImageView;
11+
12+
public class LogoActivity extends AppCompatActivity {
13+
14+
private ImageView imageView;
15+
private Animation animation;
16+
17+
@Override
18+
protected void onCreate(Bundle savedInstanceState) {
19+
super.onCreate(savedInstanceState);
20+
setContentView(R.layout.activity_logo);
21+
imageView = findViewById(R.id.logo);
22+
23+
Intent home = new Intent(LogoActivity.this, MainActivity.class);
24+
animation = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.translate_anim);
25+
imageView.startAnimation(animation);
26+
new Handler().postDelayed(new Runnable() {
27+
@Override
28+
public void run() {
29+
startActivity(home);
30+
finish();
31+
}
32+
}, 4000);
33+
}
34+
}
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
package com.enginedroid.tictactoe;
2+
3+
import static android.widget.Toast.*;
4+
5+
import androidx.appcompat.app.AppCompatActivity;
6+
7+
import android.annotation.SuppressLint;
8+
import android.os.Bundle;
9+
import android.os.Handler;
10+
import android.view.View;
11+
import android.widget.Button;
12+
import android.widget.Toast;
13+
14+
public class MainActivity extends AppCompatActivity {
15+
16+
Button btn1, btn2, btn3, btn4, btn5, btn6, btn7, btn8, btn9;
17+
String b1, b2, b3, b4, b5, b6, b7, b8, b9;
18+
int flag = 0, count=0;
19+
20+
@SuppressLint("MissingInflatedId")
21+
@Override
22+
protected void onCreate(Bundle savedInstanceState) {
23+
super.onCreate(savedInstanceState);
24+
setContentView(R.layout.activity_main);
25+
btn1 = findViewById(R.id.btn1);
26+
btn2 = findViewById(R.id.btn2);
27+
btn3 = findViewById(R.id.btn3);
28+
btn4 = findViewById(R.id.btn4);
29+
btn5 = findViewById(R.id.btn5);
30+
btn6 = findViewById(R.id.btn6);
31+
btn7 = findViewById(R.id.btn7);
32+
btn8 = findViewById(R.id.btn8);
33+
btn9 = findViewById(R.id.btn9);
34+
}
35+
36+
public void Check(View view){
37+
Button btnCurrent = (Button) view;
38+
boolean win = false;
39+
40+
if(btnCurrent.getText().toString().equals("")) {
41+
count++;
42+
if (flag == 0) {
43+
btnCurrent.setText("X");
44+
flag = 1;
45+
} else {
46+
btnCurrent.setText("O");
47+
flag = 0;
48+
}
49+
if (count > 4) {
50+
b1 = btn1.getText().toString();
51+
b2 = btn2.getText().toString();
52+
b3 = btn3.getText().toString();
53+
b4 = btn4.getText().toString();
54+
b5 = btn5.getText().toString();
55+
b6 = btn6.getText().toString();
56+
b7 = btn7.getText().toString();
57+
b8 = btn8.getText().toString();
58+
b9 = btn9.getText().toString();
59+
if (b1.equals(b2) && b2.equals(b3) && !b1.equals("")) {
60+
makeText(this, b1 + " is won!", LENGTH_SHORT).show();
61+
62+
win = true;
63+
Disable();
64+
} else if (b4.equals(b5) && b5.equals(b6) && !b4.equals("")) {
65+
makeText(this, b4 + " is won!", LENGTH_SHORT).show();
66+
win = true;
67+
Disable();
68+
} else if (b7.equals(b8) && b8.equals(b9) && !b7.equals("")) {
69+
makeText(this, b7 + " is won!", LENGTH_SHORT).show();
70+
win = true;
71+
Disable();
72+
} else if (b1.equals(b4) && b4.equals(b7) && !b1.equals("")) {
73+
makeText(this, b1 + " is won!", LENGTH_SHORT).show();
74+
win = true;
75+
Disable();
76+
} else if (b2.equals(b5) && b5.equals(b8) && !b2.equals("")) {
77+
makeText(this, b2 + " is won!", LENGTH_SHORT).show();
78+
win = true;
79+
Disable();
80+
} else if (b3.equals(b6) && b6.equals(b9) && !b3.equals("")) {
81+
makeText(this, b3 + " is won!", LENGTH_SHORT).show();
82+
win = true;
83+
Disable();
84+
} else if (b1.equals(b5) && b5.equals(b9) && !b1.equals("")) {
85+
makeText(this, b1 + " is won!", LENGTH_SHORT).show();
86+
win = true;
87+
Disable();
88+
} else if (b3.equals(b5) && b5.equals(b7) && !b3.equals("")) {
89+
makeText(this, b3 + " is won!", LENGTH_SHORT).show();
90+
win = true;
91+
Disable();
92+
}
93+
}
94+
if (count == 9 && !win) {
95+
Toast.makeText(getApplicationContext(), "Match Draw", LENGTH_SHORT).show();
96+
Disable();
97+
}
98+
}
99+
}
100+
101+
public void Disable(){
102+
btn1.setEnabled(false);
103+
btn2.setEnabled(false);
104+
btn3.setEnabled(false);
105+
btn4.setEnabled(false);
106+
btn5.setEnabled(false);
107+
btn6.setEnabled(false);
108+
btn7.setEnabled(false);
109+
btn8.setEnabled(false);
110+
btn9.setEnabled(false);
111+
new Handler().postDelayed(this::Clear, 1500);
112+
}
113+
public void Clear(){
114+
btn1.setEnabled(true);
115+
btn2.setEnabled(true);
116+
btn3.setEnabled(true);
117+
btn4.setEnabled(true);
118+
btn5.setEnabled(true);
119+
btn6.setEnabled(true);
120+
btn7.setEnabled(true);
121+
btn8.setEnabled(true);
122+
btn9.setEnabled(true);
123+
btn1.setText("");
124+
btn2.setText("");
125+
btn3.setText("");
126+
btn4.setText("");
127+
btn5.setText("");
128+
btn6.setText("");
129+
btn7.setText("");
130+
btn8.setText("");
131+
btn9.setText("");
132+
flag = 0;
133+
count = 0;
134+
}
135+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<set xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:interpolator="@android:anim/bounce_interpolator">
4+
<scale android:fromXScale="0"
5+
android:toXScale="1"
6+
android:fromYScale="0"
7+
android:toYScale="1"
8+
android:pivotX="50%"
9+
android:pivotY="50%"
10+
android:duration="3000"
11+
/>
12+
</set>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
xmlns:aapt="http://schemas.android.com/aapt"
3+
android:width="108dp"
4+
android:height="108dp"
5+
android:viewportWidth="108"
6+
android:viewportHeight="108">
7+
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
8+
<aapt:attr name="android:fillColor">
9+
<gradient
10+
android:endX="85.84757"
11+
android:endY="92.4963"
12+
android:startX="42.9492"
13+
android:startY="49.59793"
14+
android:type="linear">
15+
<item
16+
android:color="#44000000"
17+
android:offset="0.0" />
18+
<item
19+
android:color="#00000000"
20+
android:offset="1.0" />
21+
</gradient>
22+
</aapt:attr>
23+
</path>
24+
<path
25+
android:fillColor="#FFFFFF"
26+
android:fillType="nonZero"
27+
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
28+
android:strokeWidth="1"
29+
android:strokeColor="#00000000" />
30+
</vector>

0 commit comments

Comments
 (0)