Skip to content

Icasso/Tic-Tac-Toe

Repository files navigation

https://github.com/users/Icasso/projects/3#card-52155444

Tic-Tac-Toe

Description

A game of tic-tac-toe that two players can play from the beginning (with an empty grid) through to the end (until there is a draw, or one of the players wins).

The first player has to play as X and their opponent plays as O.

Objectives

Prints an empty grid at the beginning of the game. Creates a game loop where the program asks the user to enter the cell coordinates, analyzes the move for correctness and shows a grid with the changes if everything is okay. Ends the game when someone wins or there is a draw. Output the final result at the end of the game.

Example

The example below shows how the program should work. Notice that after Enter the coordinates: comes the user input.

---------
|       |
|       |
|       |
---------
Enter the coordinates: 2 2
---------
|       |
|   X   |
|       |
---------
Enter the coordinates: 2 2
This cell is occupied! Choose another one!
Enter the coordinates: two two
You should enter numbers!
Enter the coordinates: 1 4
Coordinates should be from 1 to 3!
Enter the coordinates: 1 1
---------
| O     |
|   X   |
|       |
---------
Enter the coordinates: 3 3
---------
| O     |
|   X   |
|     X |
---------
Enter the coordinates: 2 1
---------
| O     |
| O X   |
|     X |
---------
Enter the coordinates: 3 1
---------
| O     |
| O X   |
| X   X |
---------
Enter the coordinates: 2 3
---------
| O     |
| O X O |
| X   X |
---------
Enter the coordinates: 3 2
---------
| O     |
| O X O |
| X X X |
---------
X wins

About

JetBrains Academy Kotlin Project

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published