diff options
author | RossTheRoss <msattr@gmail.com> | 2019-04-16 20:18:57 -0500 |
---|---|---|
committer | RossTheRoss <msattr@gmail.com> | 2019-04-16 20:18:57 -0500 |
commit | fe0200b47ae9d0bb51907fc593dbd8828aef344e (patch) | |
tree | 8223cd7748c78d3f5ad3879eed8f73067ee52d20 /ee1301/wk6 | |
parent | AHHHHHHH (diff) | |
download | homework-fe0200b47ae9d0bb51907fc593dbd8828aef344e.tar homework-fe0200b47ae9d0bb51907fc593dbd8828aef344e.tar.gz homework-fe0200b47ae9d0bb51907fc593dbd8828aef344e.tar.bz2 homework-fe0200b47ae9d0bb51907fc593dbd8828aef344e.tar.lz homework-fe0200b47ae9d0bb51907fc593dbd8828aef344e.tar.xz homework-fe0200b47ae9d0bb51907fc593dbd8828aef344e.tar.zst homework-fe0200b47ae9d0bb51907fc593dbd8828aef344e.zip |
Fix one problem, cause several more
Diffstat (limited to '')
-rw-r--r-- | ee1301/wk6/hw6_directory/dice.cpp | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/ee1301/wk6/hw6_directory/dice.cpp b/ee1301/wk6/hw6_directory/dice.cpp index 8b41c0a..8902e0b 100644 --- a/ee1301/wk6/hw6_directory/dice.cpp +++ b/ee1301/wk6/hw6_directory/dice.cpp @@ -4,6 +4,7 @@ //HW 6A: Dice Class #include <iostream> #include <cstdlib> +#include <time.h> using namespace std; const int maxNumDie=50; @@ -16,15 +17,21 @@ private: int max; public: int roll(int min, int max); - void setMin(); int getMin(); - void setMax(); int getMax(); - Dice(); - Dice(int min, int max); + Dice() { //Default constructor for debugging purposes + min=1; + max=1; + } + Dice(int gotMin, int gotMax){ + min = gotMin; + max = gotMax; + }; }; int main() { int rounds; Dice die[50]; + int roll[50]; + int max=0, min=0; srand(time(0)); // DO NOT WRITE THIS LINE AGAIN OR ANYWHERE ELSE cout << "What do you want to roll? "; string s; @@ -45,9 +52,16 @@ int main() { for(int i=1; i < pairs[0]; i+=2) { cout << "["<<pairs[i]<<","<<pairs[i+1]<<"]" << endl; - die[i-1] = Dice(i,i+1); - cout << die.roll(pairs[i], pairs[i+1]); + die[i - 1] = Dice(pairs[i], pairs[i + 1]); + roll[i-1] = die[i-1].roll(pairs[i], pairs[i+1]); + if (roll[i-3] > roll[i-1]) { + min = roll[i-1]; + } + if (roll[i-3] < roll[i-1]) { + max = roll[i-1]; + } } + cout << max << " " << min; } @@ -64,7 +78,7 @@ int* userInputParser(string s) { // count how many '+'s or 'd's there are... int parts = 0; - for(int i=0; i < s.length(); i++) + for(unsigned int i=0; i < s.length(); i++) { if(s[i] == 'd' || s[i] == '+') { |