Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Docker Image CI

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:

build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Build the Docker image
run: docker build . --file Dockerfile --tag cpp-container:$(date +%s)
29 changes: 29 additions & 0 deletions .github/workflows/superlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# This workflow executes several linters on changed files based on languages used in your code base whenever
# you push a code or open a pull request.
#
# You can adjust the behavior by modifying this file.
# For more information, see:
# https://github.com/github/super-linter
name: Lint Code Base

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
run-lint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
# Full git history is needed to get a proper list of changed files within `super-linter`
fetch-depth: 0

- name: Lint Code Base
uses: github/super-linter@v4
env:
VALIDATE_ALL_CODEBASE: false
DEFAULT_BRANCH: "main"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3 changes: 2 additions & 1 deletion GameDie.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ 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();
unsigned int rolls = 2;
int roll = rand_r(&rolls) % roll_counter.size();
roll_counter[roll]++;
return roll + 1;
}
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,5 @@ To check for your program's adoption of the style guide, within the docker
container (see above), run **cpplint**:

`cpplint *.cpp *.h`

[![Build C++](https://github.com/SANDESHSOBARAD/Roller/actions/workflows/actions.yml/badge.svg)](https://github.com/SANDESHSOBARAD/Roller/actions/workflows/actions.yml)
Binary file added Roller
Binary file not shown.
5 changes: 2 additions & 3 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,15 @@ 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"
<< "--------------------\n"
<< "Arguments\n"
<< "--------------------\n"
<< "<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;
Expand Down