From 3b8311b09a0e20ad7dec881eeff210460508784c Mon Sep 17 00:00:00 2001 From: murthy-001 <124085326+murthy-001@users.noreply.github.com> Date: Tue, 21 Feb 2023 10:26:11 -0800 Subject: [PATCH 1/6] changes line #32 from int roll = rand_c() % roll_counter.size(); to int roll = rand() % roll_counter.size(); --- GameDie.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; } From fe49360a165ac76cc0352fe34356d3c26255f66c Mon Sep 17 00:00:00 2001 From: "sm62812@gmail.com" Date: Tue, 21 Feb 2023 10:50:28 -0800 Subject: [PATCH 2/6] cleared error in main.cpp --- main.cpp | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/main.cpp b/main.cpp index 65055f9..fd0e12d 100644 --- a/main.cpp +++ b/main.cpp @@ -1,13 +1,8 @@ -// Copyright 2022 kbuffardi -#include -#include -#include "GameDie.h" - 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,11 +10,10 @@ 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; } return 0; -} +} \ No newline at end of file From 3aa24c126a31d0b94e57c11f5d0710e121f46935 Mon Sep 17 00:00:00 2001 From: murthy-001 <124085326+murthy-001@users.noreply.github.com> Date: Tue, 21 Feb 2023 20:05:05 -0800 Subject: [PATCH 3/6] changes as per lint style --- main.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/main.cpp b/main.cpp index fd0e12d..39efd65 100644 --- a/main.cpp +++ b/main.cpp @@ -1,3 +1,8 @@ +// Copyright 2022 kbuffardi +#include +#include +#include "GameDie.h" + using std::cout; using std::endl; @@ -16,4 +21,4 @@ int main(int argc, char *argv[]) { cout << die.roll() << endl; } return 0; -} \ No newline at end of file +} From cd881ff94580ded370341d64c077029e769c0db0 Mon Sep 17 00:00:00 2001 From: murthy-001 <124085326+murthy-001@users.noreply.github.com> Date: Tue, 21 Feb 2023 20:11:12 -0800 Subject: [PATCH 4/6] added workflow , Fix#2 --- .github/workflows/c-cpp.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .github/workflows/c-cpp.yml diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml new file mode 100644 index 0000000..1ddf7b6 --- /dev/null +++ b/.github/workflows/c-cpp.yml @@ -0,0 +1,23 @@ +name: Build Cpp + +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 From 1040a7024028615d7302f484f4d2aa52f66be26f Mon Sep 17 00:00:00 2001 From: murthy-001 <124085326+murthy-001@users.noreply.github.com> Date: Tue, 21 Feb 2023 20:13:46 -0800 Subject: [PATCH 5/6] added stylelinter, fix#2 --- .github/workflows/stylelinter.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .github/workflows/stylelinter.yml diff --git a/.github/workflows/stylelinter.yml b/.github/workflows/stylelinter.yml new file mode 100644 index 0000000..c6da8df --- /dev/null +++ b/.github/workflows/stylelinter.yml @@ -0,0 +1,23 @@ +name: C++ Linter + +on: + 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 fddd44b09079613b2b8ea7282707e433bf2a6cf7 Mon Sep 17 00:00:00 2001 From: murthy-001 <124085326+murthy-001@users.noreply.github.com> Date: Tue, 21 Feb 2023 20:14:56 -0800 Subject: [PATCH 6/6] Edited readme to add status badge --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index d46f7c6..cdfaf12 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +[![Build Cpp](https://github.com/murthy-001/Roller/actions/workflows/c-cpp.yml/badge.svg)](https://github.com/murthy-001/Roller/actions/workflows/c-cpp.yml) + # Roller This repository provides a program that rolls a game die, such as the