aboutsummaryrefslogtreecommitdiffstats
path: root/ee1301/wk6/hw6_directory
diff options
context:
space:
mode:
authorMatthew Strapp <msattr@gmail.com>2019-04-17 17:00:57 -0500
committerMatthew Strapp <msattr@gmail.com>2019-04-17 17:00:57 -0500
commit7bd0457ece5cfea5e17d6f2ac04508daefc6e4e3 (patch)
treeb6cc5690621a08af346d80680edc882bb3631ace /ee1301/wk6/hw6_directory
parentfinish up (diff)
downloadhomework-7bd0457ece5cfea5e17d6f2ac04508daefc6e4e3.tar
homework-7bd0457ece5cfea5e17d6f2ac04508daefc6e4e3.tar.gz
homework-7bd0457ece5cfea5e17d6f2ac04508daefc6e4e3.tar.bz2
homework-7bd0457ece5cfea5e17d6f2ac04508daefc6e4e3.tar.lz
homework-7bd0457ece5cfea5e17d6f2ac04508daefc6e4e3.tar.xz
homework-7bd0457ece5cfea5e17d6f2ac04508daefc6e4e3.tar.zst
homework-7bd0457ece5cfea5e17d6f2ac04508daefc6e4e3.zip
LAB TIME
OH NO
Diffstat (limited to '')
-rw-r--r--ee1301/wk6/hw6_directory/strap012_HW6A.cpp12
-rw-r--r--ee1301/wk6/hw6_directory/strap012_HW6B.cpp2
2 files changed, 7 insertions, 7 deletions
diff --git a/ee1301/wk6/hw6_directory/strap012_HW6A.cpp b/ee1301/wk6/hw6_directory/strap012_HW6A.cpp
index de36cf6..d802c15 100644
--- a/ee1301/wk6/hw6_directory/strap012_HW6A.cpp
+++ b/ee1301/wk6/hw6_directory/strap012_HW6A.cpp
@@ -15,7 +15,7 @@ private:
int min;
int max;
public:
- int roll(int min, int max) {
+ int roll() {
return rand() % (max-min+1) + min;
};
Dice() { //Default constructor for debugging purposes
@@ -30,7 +30,7 @@ public:
int main() {
int rounds;
- Dice die[maxNumDie];
+ Dice die;
int roll[maxNumDie];
int max=0, min=999999, sum=0, sample=0;
double avg;
@@ -54,10 +54,10 @@ int main() {
double numRolls=0;
for (int j=0; j<rounds; j++) {
int curRoll=0;
- numRolls+=1.0;
+ numRolls+=1;
for(int i=1; i < pairs[0]; i+=2) {
- die[i-1] = Dice(pairs[i], pairs[i + 1]);
- roll[i-1] = die[i-1].roll(pairs[i], pairs[i+1]);
+ die = Dice(pairs[i], pairs[i + 1]);
+ roll[i-1] = die.roll();
curRoll += roll[i-1];
}
@@ -90,7 +90,7 @@ int* userInputParser(string s) {
string data[4*maxNumDie]; // Intermediate storage for parsing input string
- // count how many '+'s or 'd's there are...
+ // count how many '+'s or 'd's the roll[i-1] = die[i-1].roll();re are...
int parts = 0;
for(unsigned int i=0; i < s.length(); i++)
{
diff --git a/ee1301/wk6/hw6_directory/strap012_HW6B.cpp b/ee1301/wk6/hw6_directory/strap012_HW6B.cpp
index b4d7636..87ba640 100644
--- a/ee1301/wk6/hw6_directory/strap012_HW6B.cpp
+++ b/ee1301/wk6/hw6_directory/strap012_HW6B.cpp
@@ -28,7 +28,7 @@ int ff(int x) {
return x*ff(x-2);
}
} else {
- // x is 1
+ // x is 1 (or 0)
return 1;
}
}