From 1d168e2addcab49f99798468843dafa13fe9f159 Mon Sep 17 00:00:00 2001 From: Anoushka Sharma Date: Tue, 21 Feb 2023 20:06:45 -0800 Subject: [PATCH 1/6] Fixed styling and lint issues. Fix #1 --- GameDie.cpp | 2 +- main.cpp | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/GameDie.cpp b/GameDie.cpp index d8ecb3a..8dd274c 100644 --- a/GameDie.cpp +++ b/GameDie.cpp @@ -29,7 +29,7 @@ GameDie::GameDie(unsigned int num) { // generate a random number between 1-n where n is the counter size // (inclusive) and return it int GameDie::roll() { - int roll = rand_r() % roll_counter.size(); + int roll = rand() % roll_counter.size(); roll_counter[roll]++; return roll + 1; } diff --git a/main.cpp b/main.cpp index 65055f9..39efd65 100644 --- a/main.cpp +++ b/main.cpp @@ -7,7 +7,7 @@ using std::cout; using std::endl; int main(int argc, char *argv[]) { - if ( argc != 2 || std::atoi(argv[1]) < 1 ){ + if ( argc != 2 || std::atoi(argv[1]) < 1 ) { cout << "Incorrect command.\n" << "Format: ./Roller \n" << "--------------------\n" @@ -15,8 +15,7 @@ int main(int argc, char *argv[]) { << "--------------------\n" << " - Required; a number 1 or greater representing the number\n" << " of faces on the die being rolled\n"; - } - else { + } else { int faces = std::atoi(argv[1]); GameDie die(faces); cout << die.roll() << endl; From 46677d3bd7e5ca5cad5560c8191f2f9b19949df4 Mon Sep 17 00:00:00 2001 From: Anoushka Sharma Date: Tue, 21 Feb 2023 20:13:21 -0800 Subject: [PATCH 2/6] Added CI workflows for lint and build. Fixes #2 --- .github/workflows/c++&c.yml | 23 +++++++++++++++++++++++ .github/workflows/cpp-lint.yml | 25 +++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 .github/workflows/c++&c.yml create mode 100644 .github/workflows/cpp-lint.yml diff --git a/.github/workflows/c++&c.yml b/.github/workflows/c++&c.yml new file mode 100644 index 0000000..098280a --- /dev/null +++ b/.github/workflows/c++&c.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 GameDie.cpp -std=c++17 -o Roller \ No newline at end of file diff --git a/.github/workflows/cpp-lint.yml b/.github/workflows/cpp-lint.yml new file mode 100644 index 0000000..05c5ce6 --- /dev/null +++ b/.github/workflows/cpp-lint.yml @@ -0,0 +1,25 @@ +name: C++ Linter + +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 python3 python3-pip + build: + needs: install + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Build project + run: | + pip install cpplint + cpplint *.cpp *.h From dc7daa53571bc55ca772a063350548bb4a5d6322 Mon Sep 17 00:00:00 2001 From: Anoushka Sharma <35841938+Anoushka444@users.noreply.github.com> Date: Tue, 21 Feb 2023 20:16:36 -0800 Subject: [PATCH 3/6] Added Build Status badge --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index d46f7c6..025ae27 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,7 @@ +#Build Status +[![Build C++](https://github.com/Anoushka444/Roller/actions/workflows/c++&c.yml/badge.svg)](https://github.com/Anoushka444/Roller/actions/workflows/c++&c.yml) + + # Roller This repository provides a program that rolls a game die, such as the From 9476a08b401560649c025246ba6d9efe319d2dd5 Mon Sep 17 00:00:00 2001 From: Anoushka Sharma <35841938+Anoushka444@users.noreply.github.com> Date: Tue, 21 Feb 2023 20:16:53 -0800 Subject: [PATCH 4/6] Added Badge --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 025ae27..86bffa1 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ #Build Status + [![Build C++](https://github.com/Anoushka444/Roller/actions/workflows/c++&c.yml/badge.svg)](https://github.com/Anoushka444/Roller/actions/workflows/c++&c.yml) From 252eea272e2ee13cd483683802ce21cf7cd30709 Mon Sep 17 00:00:00 2001 From: Anoushka Sharma <35841938+Anoushka444@users.noreply.github.com> Date: Tue, 21 Feb 2023 20:17:14 -0800 Subject: [PATCH 5/6] Added Badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 86bffa1..95973e4 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -#Build Status +#Status [![Build C++](https://github.com/Anoushka444/Roller/actions/workflows/c++&c.yml/badge.svg)](https://github.com/Anoushka444/Roller/actions/workflows/c++&c.yml) From 7748898446544d8016a512574a5b9dc62120263d Mon Sep 17 00:00:00 2001 From: Anoushka Sharma <35841938+Anoushka444@users.noreply.github.com> Date: Tue, 21 Feb 2023 20:17:35 -0800 Subject: [PATCH 6/6] Added Build Status --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 95973e4..2f10d77 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -#Status +# Build Status [![Build C++](https://github.com/Anoushka444/Roller/actions/workflows/c++&c.yml/badge.svg)](https://github.com/Anoushka444/Roller/actions/workflows/c++&c.yml)