From 61aa71cd6997e496a47223656045f2b067584523 Mon Sep 17 00:00:00 2001 From: Manavi Date: Tue, 21 Feb 2023 10:15:24 -0800 Subject: [PATCH 1/2] Resolved issue #1 --- GameDie.cpp | 2 +- main.cpp | 7 +++---- 2 files changed, 4 insertions(+), 5 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..66b634b 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,11 +15,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 b0157feb3ba64e3a74f091b773adb9c6d0d2de99 Mon Sep 17 00:00:00 2001 From: Manavi Date: Tue, 21 Feb 2023 19:47:14 -0800 Subject: [PATCH 2/2] Resolved issue #1 --- GameDie.cpp | 2 +- main.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/GameDie.cpp b/GameDie.cpp index 8dd274c..92673c9 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() % roll_counter.size(); + int roll = random() % roll_counter.size(); roll_counter[roll]++; return roll + 1; } diff --git a/main.cpp b/main.cpp index 66b634b..39efd65 100644 --- a/main.cpp +++ b/main.cpp @@ -21,4 +21,4 @@ int main(int argc, char *argv[]) { cout << die.roll() << endl; } return 0; -} \ No newline at end of file +}