diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..791c1d1 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,24 @@ +name: Build C++ + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + install: + runs-on: ubuntu-latest + steps: + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y -f build-essential g++ cmake + + build: + needs: install + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Build project + run: make diff --git a/GameDie.cpp b/GameDie.cpp index e9fb279..1fe3d57 100644 --- a/GameDie.cpp +++ b/GameDie.cpp @@ -2,12 +2,18 @@ #include #include #include +#include + +int main() { + return 0; +} //class constructor that seeds the random number generator GameDie::GameDie() { srand(time(NULL)); roll_counter.resize(FACES); + roll_percentages.resize(FACES); for(int i=0; i GameDie::get_distribution(){ return roll_counter; } + +vector GameDie::get_percentages() { + for (int i = 0; i < (int) roll_counter.size(); i++) { + roll_percentages[i] = roll_counter[i]/(double) num_rolls; + } + return roll_percentages; +} + diff --git a/GameDie.h b/GameDie.h index 939e8f7..f02889c 100644 --- a/GameDie.h +++ b/GameDie.h @@ -11,10 +11,13 @@ class GameDie GameDie(unsigned int); int roll(); vector get_distribution(); + vector get_percentages(); private: vector roll_counter; + vector roll_percentages; const static int FACES = 6; + int num_rolls = 0; }; #endif diff --git a/README.md b/README.md index 9a8fe2c..a5eaef2 100644 --- a/README.md +++ b/README.md @@ -23,4 +23,6 @@ Once built, run the image: ...or run it with a bind mount to the current source code: -`docker run --mount type=bind,source="$(pwd)",target=/usr/src -it cpp-container` \ No newline at end of file +`docker run --mount type=bind,source="$(pwd)",target=/usr/src -it cpp-container` + +[![Build C++](https://github.com/no-bugs-only-features/GameDie/actions/workflows/build.yml/badge.svg)](https://github.com/no-bugs-only-features/GameDie/actions/workflows/build.yml)