From d11a255f5f71d51e33afaa8cb4f748cf7328064a Mon Sep 17 00:00:00 2001 From: Adrian Arredondo Date: Mon, 20 Feb 2023 11:22:27 -0800 Subject: [PATCH 1/4] Fix rand seed for overloaded constructor --- GameDie.cpp | 4 ++++ GameDie.h | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/GameDie.cpp b/GameDie.cpp index d512405..2290ce9 100644 --- a/GameDie.cpp +++ b/GameDie.cpp @@ -16,13 +16,17 @@ GameDie::GameDie() //overloaded constructor GameDie::GameDie(unsigned int num) { + srand(time(NULL)); + if( num == 0 ) { counter.resize(FACES); } else{ + FACES = num; counter.resize(num); } + for(int i=0; i counter; - const static int FACES = 6; + int FACES = 6; }; #endif From e3932b85a49a8f09008fe4aedc62aadb75bf8aef Mon Sep 17 00:00:00 2001 From: Adrian Arredondo Date: Mon, 20 Feb 2023 11:40:24 -0800 Subject: [PATCH 2/4] Changed int to unsigned int in order to be uniform throughout the program --- GameDie.cpp | 4 ++-- GameDie.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/GameDie.cpp b/GameDie.cpp index 2290ce9..6c5de71 100644 --- a/GameDie.cpp +++ b/GameDie.cpp @@ -9,7 +9,7 @@ GameDie::GameDie() srand(time(NULL)); counter.resize(FACES); - for(int i=0; i counter; - int FACES = 6; + unsigned int FACES = 6; }; #endif From 03bacb5947112ad4212799a07c9d80adc1adbcc7 Mon Sep 17 00:00:00 2001 From: Adrian Arredondo Date: Mon, 20 Feb 2023 11:46:49 -0800 Subject: [PATCH 3/4] added yml file --- .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..220b6ad --- /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++ GameDie.h -std=c++17 -Wall -Wextra -Werror -o testIO \ No newline at end of file From 1234454c83ea59bdaf21fe1cfe1f88ad1a8c94db Mon Sep 17 00:00:00 2001 From: Adrian Arredondo Date: Mon, 20 Feb 2023 11:48:14 -0800 Subject: [PATCH 4/4] added badge --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 9a8fe2c..bb054d3 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # GameDie +[![Build C++](https://github.com/adrian015/GameDie/actions/workflows/main.yml/badge.svg)](https://github.com/adrian015/GameDie/actions/workflows/main.yml) + This repository provides a class that represents a game die, such as the six-sided dice used in traditional dice game. While the die defaults to six sides, the overloaded constructor allows the developer to customize