This C++ project is a collection of several small games, including:
- Tic Tac Toe
- Guess the Number
- Crontab Game
The project is structured to allow easy addition of more games in the future. Each game has its own source file and header file. The main program presents a menu to the user to choose which game to play.
The project is organized into the following directories and files:
many-little-games
├── Makefile
├── README.md
└── src
├── guessthecrontab.cpp
├── guessthecrontab.h
├── guessthenumber.cpp
├── guessthenumber.h
├── main.cpp
├── tictactoe.cpp
├── tictactoe.h
main.cpp
: Contains the main menu and the logic to launch the selected game.guessthenumber.cpp
andguessthenumber.h
: Implementation of the "Guess the Number" game.guessthecrontab.cpp
andguessthecrontab.h
: Implementation of the "Guess the Crontab Game".tictactoe.cpp
andtictactoe.h
: Implementation of the "Tic Tac Toe" game.Makefile
: Automates the compilation process for the project.
- C++ Compiler: Ensure that
g++
or another C++ compiler is installed on your system.
-
Navigate to the root directory of the project where the
Makefile
is located. -
Run the following command in the terminal to compile the project:
make
This command will compile all the
.cpp
files in thesrc/
directory and generate an executable namedgames
.
After compilation, you have two options to run the program:
-
Manual Run: Run the program by executing the following command:
./games
-
Using Make: Alternatively, you can compile and run the program in one step using:
make run
To remove the compiled object files and the executable, run:
make clean
- Launch the program: After running
./games
, a menu will appear. - Choose a game: Enter the number corresponding to the game you want to play.
- Follow the instructions: Each game has its own set of instructions that will guide you through the gameplay.
- Exit the program: Select the "Quit" option from the menu to exit the program.
To add a new game:
- Create a new
.cpp
file and its corresponding.h
file in thesrc/
directory. - Implement the game logic in the new
.cpp
file. - Add a prototype for the game function in the corresponding
.h
file. - Include the new header file in
main.cpp
. - Add a menu option and a case in the
switch
statement inmain.cpp
to launch the new game.