From c27674d9f9b9634c2f1930f9e55229cdbd6b6e05 Mon Sep 17 00:00:00 2001 From: navjitsinghb <94209055+navjitsinghb@users.noreply.github.com> Date: Mon, 20 Feb 2023 11:25:37 -0800 Subject: [PATCH 1/3] Create main.yml --- .github/workflows/main.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..819e806 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,23 @@ +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: g++ main.cpp -std=c++17 -Wall -Wextra -Werror -o firstIO From 501cb3fad95dc4d6c33446293fa7a21a5a3459b2 Mon Sep 17 00:00:00 2001 From: Navjit Bath Date: Mon, 20 Feb 2023 11:39:23 -0800 Subject: [PATCH 2/3] made chnages to gamedie.cpp and .h files --- .github/workflows/main.yml | 2 +- GameDie.cpp | 17 +++++++++++++++++ GameDie.h | 1 + 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 819e806..6e4a079 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -20,4 +20,4 @@ jobs: steps: - uses: actions/checkout@v3 - name: Build project - run: g++ main.cpp -std=c++17 -Wall -Wextra -Werror -o firstIO + run: g++ GameDie.cpp -std=c++17 -Wall -Wextra -Werror -o Gamedie diff --git a/GameDie.cpp b/GameDie.cpp index d512405..9918c51 100644 --- a/GameDie.cpp +++ b/GameDie.cpp @@ -2,6 +2,8 @@ #include #include #include +#include +using namespace std; //class constructor that seeds the random number generator GameDie::GameDie() @@ -44,3 +46,18 @@ int GameDie::roll() vector GameDie::get_distribution(){ return counter; } +vector GameDie::get_percentages(){ + int amountRolls = 0; + for(int i=0; i < FACES; i++) + { + amountRolls += counter[i]; + } + vector percentage; + for(int i=0; i < FACES; i++) + { + percentage[i] = static_cast (counter[i]/amountRolls); + cout< get_distribution(); + vector get_percentages(); private: vector counter; From 51956c0bdf6f2f4aa9325d6f90211fe877094762 Mon Sep 17 00:00:00 2001 From: navjitsinghb <94209055+navjitsinghb@users.noreply.github.com> Date: Mon, 20 Feb 2023 11:41:08 -0800 Subject: [PATCH 3/3] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9a8fe2c..8872e81 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ +[![Build C++](https://github.com/navjitsinghb/GameDie/actions/workflows/main.yml/badge.svg)](https://github.com/navjitsinghb/GameDie/actions/workflows/main.yml) # GameDie This repository provides a class that represents a game die, such as the @@ -23,4 +24,4 @@ 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`