This repository contains some of the programs I am developing while learning C and C++ in school and online.
To compile the file, g++ <filename.cpp>
This compiles to a a.exe file
To run the file ./a.exe
To compile with a custom executable file name, g++ -o <customname.exe> <filename.cpp>
I made the standard version of Rock, Paper, Scissors(RPS)
The code is here'
The rules are simple:
- There are 3 options(1 to 3)
- You can only pick one option during a match
- When prompted, you will enter its number into the console
The options and their abilities are:
- Rock - Crushes Scissors
- Paper - Covers Rock
- Scissors - Cuts paper
This is a basic but extended version of RPS based on notes from Sam Kass.
The code is here
It introduces Lizard and Spock to the standard version.
The rules stay the same but there are 2 additional options and abilities: 4. Lizard - Poisons Spock and eats Paper 5. Spock - Smashes Scissors and vaporizes Rock
For the third version of the game, I switched up gears a bit and split it into 3 files:
- The main file which initializes the game and starts it. (13 lines of code)
- The header file which contains the class definition and the class members' declaration. (26 lines of code)
- The logic file Where the game logic is coded. Also where the class member methods declared in the header file are defined. (351 lines of code)
390 total lines of code
I also moved the code to its own folder to make it easier to differentiate from the second version(Program 2).
This is the fourth and last version of the game. It has a GUI that allows players to either type in their choice or click on an interactive graphic on their screen.
I haven't yet got to learning GUI with C/C++. Once I have, I will upload the code for Program 4.
I will also add comments to the code when I have time