Skip to content

milojezek/tic-tac-toe

Repository files navigation

Objectives

You should write a program that:

  • 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

You need to output the final result at the end of the game.

Example

The example below shows how your 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 project

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages