Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CMake project for C++ variant #9

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions C++/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Debug
.project
.cproject
build
16 changes: 16 additions & 0 deletions C++/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
cmake_minimum_required(VERSION 3.5.0)
project(Trivia VERSION 0.1.0 LANGUAGES C CXX)

include(CTest)
enable_testing()

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_CXX_STANDARD 14)

add_compile_options(-g -Wall -Wextra -Werror)

add_executable(Trivia Game.cpp GameRunner.cpp)

set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)
10 changes: 5 additions & 5 deletions C++/Game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

using namespace std;

Game::Game() : currentPlayer(0), places({}), purses({}){
Game::Game() : places{}, purses{}, currentPlayer(0) {
for (int i = 0; i < 50; i++)
{

Expand Down Expand Up @@ -148,14 +148,14 @@ bool Game::wasCorrectlyAnswered()

bool winner = didPlayerWin();
currentPlayer++;
if (currentPlayer == players.size()) currentPlayer = 0;
if (currentPlayer == (int)players.size()) currentPlayer = 0;

return winner;
}
else
{
currentPlayer++;
if (currentPlayer == players.size()) currentPlayer = 0;
if (currentPlayer == (int)players.size()) currentPlayer = 0;
return true;
}

Expand All @@ -174,7 +174,7 @@ bool Game::wasCorrectlyAnswered()

bool winner = didPlayerWin();
currentPlayer++;
if (currentPlayer == players.size()) currentPlayer = 0;
if (currentPlayer == (int)players.size()) currentPlayer = 0;

return winner;
}
Expand All @@ -187,7 +187,7 @@ bool Game::wrongAnswer()
inPenaltyBox[currentPlayer] = true;

currentPlayer++;
if (currentPlayer == players.size()) currentPlayer = 0;
if (currentPlayer == (int)players.size()) currentPlayer = 0;
return true;
}

Expand Down