The Tic Tac Toe Game is based on a two-player game developed in kotlin.. Each player chooses between X and O. Player play one move at a time simultaneously. In a move, a player can choose any position from a 3×3 grid. The goal here is to get three consecutive X or O in a horizontal, vertical, or diagonal direction. There will be a single activity in this application. This activity will show a 3×3 grid. The status of the game will be displayed at the bottom.
Student can submit it as an assignment.
children’s can develop this app , it will grow their interest in coding.
It will have a grid with 9 boxes or cells. Then it’ll have the Restart button. This button can help the player to restart the game at any time they like. Once the game is over the app will declare who lost the game. If no one wins, it will declare that it was a draw match.
The players are supposed to fill each cell alternatively. The Player one would need to fill the cell with ‘X’and the player will use ‘O’ to fill the cells.
Creating Tic-Tac-Toe in Android Studio
- Create a new project by clicking New Projects⇒ fill the required details.
- Create Gridview for board in XML
- Start Coding in MainActivity.kt
- Click listener for all buttons
- create 2 players
- allow player to play one by one
- implement functionality for tie and winning
- implement functionality for reset board
- show result on top of screen
Student will learn:
- start creating new project in android studio
- basic structure of android studio
- xml layouts
- Gradle libraries
- if else statements
- buttons and button click
- logics for game like winning ‘o’ , ‘x’ or Tie game
- data types
- fonts styles
We are using android studio here. Android Studio is the official integrated development environment (IDE) for Google’s Android operating system, built on JetBrains’ IntelliJ IDEA software and designed specifically for Android development. It is available for download on Windows, macOS and Linux based operating systems or as a subscription-based service in 2020. It is a replacement for the Eclipse Android Development Tools.
What is Android Architecture?
Before studying the Architecture, let us go through some of the features of the Android Operating system.
- Android OS can be customized as per the need, and hence we can notice many avatars of this OS are deployed in different mobile devices with multiple unique features.
- It supports all mobile connectivity technologies viz., Wi-Fi, CDMA, GSM, NFC, Bluetooth etc., and basic functionalities like telephony, SMS and data transfer. With this connectivity, data can be transferred back and forth between devices thru various apps.
- It provides Interfaces (APIs) that support location dependent services such as GPS.
- SQLite database provides storage functionalities needed by Android. Being a lightweight database, it enables simpler storage and quicker retrieval of data.
- It supports all versions of multimedia files (Audio/Video) and integrates a Microphone, Camera, Accelerometer and speaker for effective management of recording, playback operations.
- HTML5 and CSS3 are supported for the development of an intuitive and impressive front end screen.
- It allows multiple windows to be active at a time, performing different tasks.
- Graphics 2D/3D are supported.
- Supports NFC technology that enables connectivity between two NFC enabled devices just by touching devices with each other.
- Multi-languages support, User-adjustable widgets, Google cloud messaging are the other features.
What are the components of an Android application?
There are some necessary building blocks that an Android application consists of. These loosely coupled components are bound by the application manifest file which contains the description of each component and how they interact. The manifest file also contains the app’s metadata, its hardware configuration, and platform requirements, external libraries, and required permissions. There are the following main components of an android app:
3. Content Providers
4. Broadcast Receivers
Why kotlin over java :
- Null Safety. One of the biggest advantage of Kotlin is that it’s null safe.
- Kotlin is more expressive. Kotlin is concise and expressive which means you can write more functionality with much less code.
- Kotlin is Functional.
- Extension Functions.
- Smart Casts.