In this project, we built a Tic Tac Toe game. The main goal is to put into practice the main concepts of Object Oriented Programming. Particularly, classes, objects and access to their attributes.
- Ruby
- VsCode
This game consists of 2 players.
The first player to enter their name, or Player One, is assigned 'X', and the second player, or Player Two, is assigned 'O'.
A board, which consists of a 3x3 grid cell, is displayed.
The game starts with the first player choosing any of the cells from 1 to 9. The board is updated with the player's symbol ('X' or 'O') at the cell they chose.
The next player then picks a cell number and the game continues in alternating fashion.
The objective of the game is to fill in 3 cells in a row with your letter, either horizontally, vertically, or diagonally.
The game ends in one of 2 scenarios: One player succeeds at filling 3 cells in a row or all cells are filled and no player wins, that is a draw. The game will output the appropriate message in either case.
Note that you can't enter anything other than a number from 1-9 when picking a cell. The game will throw an error and ask you to pick a valid number.
Also, you can't pick a cell that has been previously filled with either an 'X' or an 'O'. The game will inform you that the cell is not empty.
To get a local copy up and running follow these simple example steps.
-
Clone this repository into your local machine
-
Run the main file by navigating to whatever directory you cloned the repo into and typing the following in your command line:
cd tic-tac-toe/bin
ruby main
An interesting thing to note here is that, since the main file is an executable, you should be able to run it, even if you're not in the tic-tac-toe folder. All you have to do is type the command main
on the command line and the game should run, even without using the ruby
prefix. However, seeing as different environments can be unpredictable, if that doesn't work then the above steps are the surest to get the game running.
- Rubocop via Github Actions
👤 Ramsey Njire
- Github: @RamseyNjire
- Twitter: @untakenramram
- Linkedin: Ramsey Njire
👤 Peris Ndanu
- Github: @mimipeshy
- Linkedin: Peris Ndanu
Contributions, issues and feature requests are welcome!
Feel free to check the issues page.
Give a ⭐️ if you like this project!
This project is MIT licensed.