From a3ecb12365cf72b85804295f7b8bb5a5026801d1 Mon Sep 17 00:00:00 2001 From: Clsmith2 <99225328+Clsmith2@users.noreply.github.com> Date: Mon, 20 Feb 2023 11:36:14 -0800 Subject: [PATCH 1/7] Added get percentages feature --- GameDie.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/GameDie.cpp b/GameDie.cpp index d512405..01007ab 100644 --- a/GameDie.cpp +++ b/GameDie.cpp @@ -44,3 +44,9 @@ int GameDie::roll() vector GameDie::get_distribution(){ return counter; } +vector GameDie::get_percentages(){ + for(int i = 0; i < counter.size(); i++){ + percentages[i] = counter[i]/counter.size(); + } + return percentages; +} From 1d6321d0df6b39f66faca6fe46f61354863c23fc Mon Sep 17 00:00:00 2001 From: Clsmith2 <99225328+Clsmith2@users.noreply.github.com> Date: Mon, 20 Feb 2023 11:36:58 -0800 Subject: [PATCH 2/7] Added get percentages feature --- GameDie.h | 1 + 1 file changed, 1 insertion(+) diff --git a/GameDie.h b/GameDie.h index 54d69ba..26a428f 100644 --- a/GameDie.h +++ b/GameDie.h @@ -11,6 +11,7 @@ class GameDie GameDie(unsigned int); int roll(); vector get_distribution(); + vector percentages(); private: vector counter; From b51ed1f47839a7bf8427d5eaa6c5ea2f7a5b48f9 Mon Sep 17 00:00:00 2001 From: Clsmith2 <99225328+Clsmith2@users.noreply.github.com> Date: Mon, 20 Feb 2023 11:38:43 -0800 Subject: [PATCH 3/7] Added yml file for continuous integration --- .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 65ecc4f6f8869bdc4bf961cbbf9a3adce49829ae Mon Sep 17 00:00:00 2001 From: Clsmith2 <99225328+Clsmith2@users.noreply.github.com> Date: Mon, 20 Feb 2023 11:40:31 -0800 Subject: [PATCH 4/7] made it GameDie.cpp that gets run made it GameDie.cpp that gets run --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 819e806..bc3d466 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 firstIO From 31347995613d979574921b8219d656396f2108d0 Mon Sep 17 00:00:00 2001 From: Clsmith2 <99225328+Clsmith2@users.noreply.github.com> Date: Mon, 20 Feb 2023 11:44:30 -0800 Subject: [PATCH 5/7] Update GameDie.h --- GameDie.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GameDie.h b/GameDie.h index 26a428f..e5bec0b 100644 --- a/GameDie.h +++ b/GameDie.h @@ -11,7 +11,7 @@ class GameDie GameDie(unsigned int); int roll(); vector get_distribution(); - vector percentages(); + vector get_percentages(); private: vector counter; From 3d0c0367739d95f282776125937d1849b048ae96 Mon Sep 17 00:00:00 2001 From: Clsmith2 <99225328+Clsmith2@users.noreply.github.com> Date: Mon, 20 Feb 2023 11:45:02 -0800 Subject: [PATCH 6/7] Made it get_percentages --- GameDie.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/GameDie.cpp b/GameDie.cpp index 01007ab..7812516 100644 --- a/GameDie.cpp +++ b/GameDie.cpp @@ -46,7 +46,7 @@ vector GameDie::get_distribution(){ } vector GameDie::get_percentages(){ for(int i = 0; i < counter.size(); i++){ - percentages[i] = counter[i]/counter.size(); + get_percentages[i] = counter[i]/counter.size(); } - return percentages; + return get_percentages; } From f2a26db56b866a938f75c9c44bf168f6f3c746cd Mon Sep 17 00:00:00 2001 From: Clsmith2 <99225328+Clsmith2@users.noreply.github.com> Date: Mon, 20 Feb 2023 11:47:01 -0800 Subject: [PATCH 7/7] Added build badge --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9a8fe2c..50aab6c 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ +[![Build C++](https://github.com/Clsmith2/GameDie/actions/workflows/main.yml/badge.svg)](https://github.com/Clsmith2/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`