Using a class to randomize dice rolls









up vote
-1
down vote

favorite












I'm writing a dice game program that creates a die for the user and computer, then asks for user name, number of sides on dice, and how many iterations the user would like to play with the computer. Then have the program check after each roll to see which roll is higher and at the end of the iterations it writes back the total wins for each user and computer and who the winner is. The problem i'm having is that I need to create a roll() class to randomize the dice and set it to a value for the users roll and computers roll and i'm getting this error...



Exception in thread "main" java.lang.IllegalArgumentException: bound must be positive
at java.util.Random.nextInt(Random.java:388)
at classwork6_3.Die.roll(Die.java:52)
at classwork6_3.ClassWork6_3.main(ClassWork6_3.java:29)


Here is my main() class...



package classwork6_3;
import java.util.*;

public class ClassWork6_3

public static void main(String args)

Scanner s = new Scanner(System.in);
Random r = new Random();

System.out.print("Enter user's name: ");
String name = s.nextLine();
int value = 0;
int value2 = 0;
System.out.print("How many sides does the die have?: ");
int sides = s.nextInt();
s.nextLine();
System.out.print("How many times would you like to roll?: ");
int numRoll = s.nextInt();
int counter = 0;
int counter2 = 0;

Die user = new Die(name, sides, value);
Die comp = new Die(value);

for(int i = 1; i<= numRoll; i++)

value = r.nextInt(user.roll(sides)) + 1;
value2 = r.nextInt(comp.roll(sides)) + 1;

System.out.printf("%s rolled: %dn", user.getOwner(), user.getValue());
System.out.print("Computer rolled: " + comp.getValue() + "nn");

if(value > value2)
counter++;
else if(value2 > value)
counter2++;



System.out.printf("%s TOTAL WINS: %dn", user.getOwner(), counter);
System.out.print("Computer TOTAL WINS: " + counter2 + "nn");
if(counter > counter2)

System.out.printf("%s wins!!n", user.getOwner());
else if(counter2 > counter)

System.out.print("Computer winsn");
else

System.out.print("It's a tie!n");







Here is my Die() class...



package classwork6_3;
import java.util.*;


public class Die

Random r = new Random();

private int sides;
private int value;
private String owner;


public Die(String owner, int sides, int value)

this.sides = sides;
this.value = value;
this.owner = owner;

public Die (int value)

this.value = value;


public int getSides()

return sides;

public int getValue()

return value;

public String getOwner()

return owner;

public void setSides(int sides)

this.sides = sides;

public void setValue(int value)

this.value = value;

public void setOwner(String owner)

this.owner = owner;

public int roll(int rand)

rand = r.nextInt(value);

return value;













share|improve this question

















  • 1




    Are you entering a negative number?
    – Nicholas K
    Nov 11 at 6:22










  • This doesn't make sense to me. Why do you need a parameter to roll(), when the number of sides should (hint, it's not for comp) already be stored in the class? Why are you calling nextInt() with value? Shouldn't you be going for a random number bounded by the number of sides? Why aren't you actually returning the random number generated in roll()?
    – Matt
    Nov 11 at 6:25










  • @NicholasK, i'm not entering any number, the program is suppose to randomly generate a number based on the number of sides I tell it that the dice is.
    – Matt L.
    Nov 11 at 6:54










  • @Matt, the instructions for this assignment wants me to make a class called roll() inside the Die() class. I'm just trying to enter anything that will make this code operate properly, that's where i'm stuck.
    – Matt L.
    Nov 11 at 6:55















up vote
-1
down vote

favorite












I'm writing a dice game program that creates a die for the user and computer, then asks for user name, number of sides on dice, and how many iterations the user would like to play with the computer. Then have the program check after each roll to see which roll is higher and at the end of the iterations it writes back the total wins for each user and computer and who the winner is. The problem i'm having is that I need to create a roll() class to randomize the dice and set it to a value for the users roll and computers roll and i'm getting this error...



Exception in thread "main" java.lang.IllegalArgumentException: bound must be positive
at java.util.Random.nextInt(Random.java:388)
at classwork6_3.Die.roll(Die.java:52)
at classwork6_3.ClassWork6_3.main(ClassWork6_3.java:29)


Here is my main() class...



package classwork6_3;
import java.util.*;

public class ClassWork6_3

public static void main(String args)

Scanner s = new Scanner(System.in);
Random r = new Random();

System.out.print("Enter user's name: ");
String name = s.nextLine();
int value = 0;
int value2 = 0;
System.out.print("How many sides does the die have?: ");
int sides = s.nextInt();
s.nextLine();
System.out.print("How many times would you like to roll?: ");
int numRoll = s.nextInt();
int counter = 0;
int counter2 = 0;

Die user = new Die(name, sides, value);
Die comp = new Die(value);

for(int i = 1; i<= numRoll; i++)

value = r.nextInt(user.roll(sides)) + 1;
value2 = r.nextInt(comp.roll(sides)) + 1;

System.out.printf("%s rolled: %dn", user.getOwner(), user.getValue());
System.out.print("Computer rolled: " + comp.getValue() + "nn");

if(value > value2)
counter++;
else if(value2 > value)
counter2++;



System.out.printf("%s TOTAL WINS: %dn", user.getOwner(), counter);
System.out.print("Computer TOTAL WINS: " + counter2 + "nn");
if(counter > counter2)

System.out.printf("%s wins!!n", user.getOwner());
else if(counter2 > counter)

System.out.print("Computer winsn");
else

System.out.print("It's a tie!n");







Here is my Die() class...



package classwork6_3;
import java.util.*;


public class Die

Random r = new Random();

private int sides;
private int value;
private String owner;


public Die(String owner, int sides, int value)

this.sides = sides;
this.value = value;
this.owner = owner;

public Die (int value)

this.value = value;


public int getSides()

return sides;

public int getValue()

return value;

public String getOwner()

return owner;

public void setSides(int sides)

this.sides = sides;

public void setValue(int value)

this.value = value;

public void setOwner(String owner)

this.owner = owner;

public int roll(int rand)

rand = r.nextInt(value);

return value;













share|improve this question

















  • 1




    Are you entering a negative number?
    – Nicholas K
    Nov 11 at 6:22










  • This doesn't make sense to me. Why do you need a parameter to roll(), when the number of sides should (hint, it's not for comp) already be stored in the class? Why are you calling nextInt() with value? Shouldn't you be going for a random number bounded by the number of sides? Why aren't you actually returning the random number generated in roll()?
    – Matt
    Nov 11 at 6:25










  • @NicholasK, i'm not entering any number, the program is suppose to randomly generate a number based on the number of sides I tell it that the dice is.
    – Matt L.
    Nov 11 at 6:54










  • @Matt, the instructions for this assignment wants me to make a class called roll() inside the Die() class. I'm just trying to enter anything that will make this code operate properly, that's where i'm stuck.
    – Matt L.
    Nov 11 at 6:55













up vote
-1
down vote

favorite









up vote
-1
down vote

favorite











I'm writing a dice game program that creates a die for the user and computer, then asks for user name, number of sides on dice, and how many iterations the user would like to play with the computer. Then have the program check after each roll to see which roll is higher and at the end of the iterations it writes back the total wins for each user and computer and who the winner is. The problem i'm having is that I need to create a roll() class to randomize the dice and set it to a value for the users roll and computers roll and i'm getting this error...



Exception in thread "main" java.lang.IllegalArgumentException: bound must be positive
at java.util.Random.nextInt(Random.java:388)
at classwork6_3.Die.roll(Die.java:52)
at classwork6_3.ClassWork6_3.main(ClassWork6_3.java:29)


Here is my main() class...



package classwork6_3;
import java.util.*;

public class ClassWork6_3

public static void main(String args)

Scanner s = new Scanner(System.in);
Random r = new Random();

System.out.print("Enter user's name: ");
String name = s.nextLine();
int value = 0;
int value2 = 0;
System.out.print("How many sides does the die have?: ");
int sides = s.nextInt();
s.nextLine();
System.out.print("How many times would you like to roll?: ");
int numRoll = s.nextInt();
int counter = 0;
int counter2 = 0;

Die user = new Die(name, sides, value);
Die comp = new Die(value);

for(int i = 1; i<= numRoll; i++)

value = r.nextInt(user.roll(sides)) + 1;
value2 = r.nextInt(comp.roll(sides)) + 1;

System.out.printf("%s rolled: %dn", user.getOwner(), user.getValue());
System.out.print("Computer rolled: " + comp.getValue() + "nn");

if(value > value2)
counter++;
else if(value2 > value)
counter2++;



System.out.printf("%s TOTAL WINS: %dn", user.getOwner(), counter);
System.out.print("Computer TOTAL WINS: " + counter2 + "nn");
if(counter > counter2)

System.out.printf("%s wins!!n", user.getOwner());
else if(counter2 > counter)

System.out.print("Computer winsn");
else

System.out.print("It's a tie!n");







Here is my Die() class...



package classwork6_3;
import java.util.*;


public class Die

Random r = new Random();

private int sides;
private int value;
private String owner;


public Die(String owner, int sides, int value)

this.sides = sides;
this.value = value;
this.owner = owner;

public Die (int value)

this.value = value;


public int getSides()

return sides;

public int getValue()

return value;

public String getOwner()

return owner;

public void setSides(int sides)

this.sides = sides;

public void setValue(int value)

this.value = value;

public void setOwner(String owner)

this.owner = owner;

public int roll(int rand)

rand = r.nextInt(value);

return value;













share|improve this question













I'm writing a dice game program that creates a die for the user and computer, then asks for user name, number of sides on dice, and how many iterations the user would like to play with the computer. Then have the program check after each roll to see which roll is higher and at the end of the iterations it writes back the total wins for each user and computer and who the winner is. The problem i'm having is that I need to create a roll() class to randomize the dice and set it to a value for the users roll and computers roll and i'm getting this error...



Exception in thread "main" java.lang.IllegalArgumentException: bound must be positive
at java.util.Random.nextInt(Random.java:388)
at classwork6_3.Die.roll(Die.java:52)
at classwork6_3.ClassWork6_3.main(ClassWork6_3.java:29)


Here is my main() class...



package classwork6_3;
import java.util.*;

public class ClassWork6_3

public static void main(String args)

Scanner s = new Scanner(System.in);
Random r = new Random();

System.out.print("Enter user's name: ");
String name = s.nextLine();
int value = 0;
int value2 = 0;
System.out.print("How many sides does the die have?: ");
int sides = s.nextInt();
s.nextLine();
System.out.print("How many times would you like to roll?: ");
int numRoll = s.nextInt();
int counter = 0;
int counter2 = 0;

Die user = new Die(name, sides, value);
Die comp = new Die(value);

for(int i = 1; i<= numRoll; i++)

value = r.nextInt(user.roll(sides)) + 1;
value2 = r.nextInt(comp.roll(sides)) + 1;

System.out.printf("%s rolled: %dn", user.getOwner(), user.getValue());
System.out.print("Computer rolled: " + comp.getValue() + "nn");

if(value > value2)
counter++;
else if(value2 > value)
counter2++;



System.out.printf("%s TOTAL WINS: %dn", user.getOwner(), counter);
System.out.print("Computer TOTAL WINS: " + counter2 + "nn");
if(counter > counter2)

System.out.printf("%s wins!!n", user.getOwner());
else if(counter2 > counter)

System.out.print("Computer winsn");
else

System.out.print("It's a tie!n");







Here is my Die() class...



package classwork6_3;
import java.util.*;


public class Die

Random r = new Random();

private int sides;
private int value;
private String owner;


public Die(String owner, int sides, int value)

this.sides = sides;
this.value = value;
this.owner = owner;

public Die (int value)

this.value = value;


public int getSides()

return sides;

public int getValue()

return value;

public String getOwner()

return owner;

public void setSides(int sides)

this.sides = sides;

public void setValue(int value)

this.value = value;

public void setOwner(String owner)

this.owner = owner;

public int roll(int rand)

rand = r.nextInt(value);

return value;










java






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 11 at 6:14









Matt L.

218




218







  • 1




    Are you entering a negative number?
    – Nicholas K
    Nov 11 at 6:22










  • This doesn't make sense to me. Why do you need a parameter to roll(), when the number of sides should (hint, it's not for comp) already be stored in the class? Why are you calling nextInt() with value? Shouldn't you be going for a random number bounded by the number of sides? Why aren't you actually returning the random number generated in roll()?
    – Matt
    Nov 11 at 6:25










  • @NicholasK, i'm not entering any number, the program is suppose to randomly generate a number based on the number of sides I tell it that the dice is.
    – Matt L.
    Nov 11 at 6:54










  • @Matt, the instructions for this assignment wants me to make a class called roll() inside the Die() class. I'm just trying to enter anything that will make this code operate properly, that's where i'm stuck.
    – Matt L.
    Nov 11 at 6:55













  • 1




    Are you entering a negative number?
    – Nicholas K
    Nov 11 at 6:22










  • This doesn't make sense to me. Why do you need a parameter to roll(), when the number of sides should (hint, it's not for comp) already be stored in the class? Why are you calling nextInt() with value? Shouldn't you be going for a random number bounded by the number of sides? Why aren't you actually returning the random number generated in roll()?
    – Matt
    Nov 11 at 6:25










  • @NicholasK, i'm not entering any number, the program is suppose to randomly generate a number based on the number of sides I tell it that the dice is.
    – Matt L.
    Nov 11 at 6:54










  • @Matt, the instructions for this assignment wants me to make a class called roll() inside the Die() class. I'm just trying to enter anything that will make this code operate properly, that's where i'm stuck.
    – Matt L.
    Nov 11 at 6:55








1




1




Are you entering a negative number?
– Nicholas K
Nov 11 at 6:22




Are you entering a negative number?
– Nicholas K
Nov 11 at 6:22












This doesn't make sense to me. Why do you need a parameter to roll(), when the number of sides should (hint, it's not for comp) already be stored in the class? Why are you calling nextInt() with value? Shouldn't you be going for a random number bounded by the number of sides? Why aren't you actually returning the random number generated in roll()?
– Matt
Nov 11 at 6:25




This doesn't make sense to me. Why do you need a parameter to roll(), when the number of sides should (hint, it's not for comp) already be stored in the class? Why are you calling nextInt() with value? Shouldn't you be going for a random number bounded by the number of sides? Why aren't you actually returning the random number generated in roll()?
– Matt
Nov 11 at 6:25












@NicholasK, i'm not entering any number, the program is suppose to randomly generate a number based on the number of sides I tell it that the dice is.
– Matt L.
Nov 11 at 6:54




@NicholasK, i'm not entering any number, the program is suppose to randomly generate a number based on the number of sides I tell it that the dice is.
– Matt L.
Nov 11 at 6:54












@Matt, the instructions for this assignment wants me to make a class called roll() inside the Die() class. I'm just trying to enter anything that will make this code operate properly, that's where i'm stuck.
– Matt L.
Nov 11 at 6:55





@Matt, the instructions for this assignment wants me to make a class called roll() inside the Die() class. I'm just trying to enter anything that will make this code operate properly, that's where i'm stuck.
– Matt L.
Nov 11 at 6:55













2 Answers
2






active

oldest

votes

















up vote
1
down vote



accepted










Here are the issues with your code :




  1. You are never returning the random value generated by the roll(...) method



    public int roll(int rand)
    rand = r.nextInt(value);
    return value;



    Change it to



    public int roll(int rand) 
    return r.nextInt(rand);




  2. Within the for-loop all you need to do is just call the roll()
    method. Since it already calculates the random value of the die, there is no need for you to call r.nextInt() again.



    value = r.nextInt(user.roll(sides)) + 1;
    value2 = r.nextInt(comp.roll(sides)) + 1;


    Change it to



    value = user.roll(sides) + 1;
    value2 = comp.roll(sides) + 1;



  3. Now print out the values using :



    System.out.printf("%s rolled: %dn", user.getOwner(), value);
    System.out.print("Computer rolled: " + value2 + "nn");


Your code will work as expected after performing the above mentioned steps. Also as a side note do not use variable names that have an ambiguous meaning like value, value2 etc.






share|improve this answer





























    up vote
    0
    down vote













    Whenever you make a new die, your value is never changed from zero, causing that error to pop-up since the range it would be looking through whenever you call roll(), acording to your Die class, is 0 to 0. Change value to the value the user puts in and the make a new die.






    share|improve this answer






















    • This should solve the error, however I don't believe that the program will function correctly. Just looking at roll(), you can see that the random value generated is never actually used.
      – Matt
      Nov 11 at 6:39










    • Yea, that confused me. When I was looking at the code, I guessed that was a typo since that parameter was never used whenever he called roll()
      – Kyle Henry
      Nov 11 at 6:42











    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53246332%2fusing-a-class-to-randomize-dice-rolls%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    1
    down vote



    accepted










    Here are the issues with your code :




    1. You are never returning the random value generated by the roll(...) method



      public int roll(int rand)
      rand = r.nextInt(value);
      return value;



      Change it to



      public int roll(int rand) 
      return r.nextInt(rand);




    2. Within the for-loop all you need to do is just call the roll()
      method. Since it already calculates the random value of the die, there is no need for you to call r.nextInt() again.



      value = r.nextInt(user.roll(sides)) + 1;
      value2 = r.nextInt(comp.roll(sides)) + 1;


      Change it to



      value = user.roll(sides) + 1;
      value2 = comp.roll(sides) + 1;



    3. Now print out the values using :



      System.out.printf("%s rolled: %dn", user.getOwner(), value);
      System.out.print("Computer rolled: " + value2 + "nn");


    Your code will work as expected after performing the above mentioned steps. Also as a side note do not use variable names that have an ambiguous meaning like value, value2 etc.






    share|improve this answer


























      up vote
      1
      down vote



      accepted










      Here are the issues with your code :




      1. You are never returning the random value generated by the roll(...) method



        public int roll(int rand)
        rand = r.nextInt(value);
        return value;



        Change it to



        public int roll(int rand) 
        return r.nextInt(rand);




      2. Within the for-loop all you need to do is just call the roll()
        method. Since it already calculates the random value of the die, there is no need for you to call r.nextInt() again.



        value = r.nextInt(user.roll(sides)) + 1;
        value2 = r.nextInt(comp.roll(sides)) + 1;


        Change it to



        value = user.roll(sides) + 1;
        value2 = comp.roll(sides) + 1;



      3. Now print out the values using :



        System.out.printf("%s rolled: %dn", user.getOwner(), value);
        System.out.print("Computer rolled: " + value2 + "nn");


      Your code will work as expected after performing the above mentioned steps. Also as a side note do not use variable names that have an ambiguous meaning like value, value2 etc.






      share|improve this answer
























        up vote
        1
        down vote



        accepted







        up vote
        1
        down vote



        accepted






        Here are the issues with your code :




        1. You are never returning the random value generated by the roll(...) method



          public int roll(int rand)
          rand = r.nextInt(value);
          return value;



          Change it to



          public int roll(int rand) 
          return r.nextInt(rand);




        2. Within the for-loop all you need to do is just call the roll()
          method. Since it already calculates the random value of the die, there is no need for you to call r.nextInt() again.



          value = r.nextInt(user.roll(sides)) + 1;
          value2 = r.nextInt(comp.roll(sides)) + 1;


          Change it to



          value = user.roll(sides) + 1;
          value2 = comp.roll(sides) + 1;



        3. Now print out the values using :



          System.out.printf("%s rolled: %dn", user.getOwner(), value);
          System.out.print("Computer rolled: " + value2 + "nn");


        Your code will work as expected after performing the above mentioned steps. Also as a side note do not use variable names that have an ambiguous meaning like value, value2 etc.






        share|improve this answer














        Here are the issues with your code :




        1. You are never returning the random value generated by the roll(...) method



          public int roll(int rand)
          rand = r.nextInt(value);
          return value;



          Change it to



          public int roll(int rand) 
          return r.nextInt(rand);




        2. Within the for-loop all you need to do is just call the roll()
          method. Since it already calculates the random value of the die, there is no need for you to call r.nextInt() again.



          value = r.nextInt(user.roll(sides)) + 1;
          value2 = r.nextInt(comp.roll(sides)) + 1;


          Change it to



          value = user.roll(sides) + 1;
          value2 = comp.roll(sides) + 1;



        3. Now print out the values using :



          System.out.printf("%s rolled: %dn", user.getOwner(), value);
          System.out.print("Computer rolled: " + value2 + "nn");


        Your code will work as expected after performing the above mentioned steps. Also as a side note do not use variable names that have an ambiguous meaning like value, value2 etc.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 11 at 10:38

























        answered Nov 11 at 10:25









        Nicholas K

        4,20241029




        4,20241029






















            up vote
            0
            down vote













            Whenever you make a new die, your value is never changed from zero, causing that error to pop-up since the range it would be looking through whenever you call roll(), acording to your Die class, is 0 to 0. Change value to the value the user puts in and the make a new die.






            share|improve this answer






















            • This should solve the error, however I don't believe that the program will function correctly. Just looking at roll(), you can see that the random value generated is never actually used.
              – Matt
              Nov 11 at 6:39










            • Yea, that confused me. When I was looking at the code, I guessed that was a typo since that parameter was never used whenever he called roll()
              – Kyle Henry
              Nov 11 at 6:42















            up vote
            0
            down vote













            Whenever you make a new die, your value is never changed from zero, causing that error to pop-up since the range it would be looking through whenever you call roll(), acording to your Die class, is 0 to 0. Change value to the value the user puts in and the make a new die.






            share|improve this answer






















            • This should solve the error, however I don't believe that the program will function correctly. Just looking at roll(), you can see that the random value generated is never actually used.
              – Matt
              Nov 11 at 6:39










            • Yea, that confused me. When I was looking at the code, I guessed that was a typo since that parameter was never used whenever he called roll()
              – Kyle Henry
              Nov 11 at 6:42













            up vote
            0
            down vote










            up vote
            0
            down vote









            Whenever you make a new die, your value is never changed from zero, causing that error to pop-up since the range it would be looking through whenever you call roll(), acording to your Die class, is 0 to 0. Change value to the value the user puts in and the make a new die.






            share|improve this answer














            Whenever you make a new die, your value is never changed from zero, causing that error to pop-up since the range it would be looking through whenever you call roll(), acording to your Die class, is 0 to 0. Change value to the value the user puts in and the make a new die.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Nov 11 at 6:40

























            answered Nov 11 at 6:35









            Kyle Henry

            14




            14











            • This should solve the error, however I don't believe that the program will function correctly. Just looking at roll(), you can see that the random value generated is never actually used.
              – Matt
              Nov 11 at 6:39










            • Yea, that confused me. When I was looking at the code, I guessed that was a typo since that parameter was never used whenever he called roll()
              – Kyle Henry
              Nov 11 at 6:42

















            • This should solve the error, however I don't believe that the program will function correctly. Just looking at roll(), you can see that the random value generated is never actually used.
              – Matt
              Nov 11 at 6:39










            • Yea, that confused me. When I was looking at the code, I guessed that was a typo since that parameter was never used whenever he called roll()
              – Kyle Henry
              Nov 11 at 6:42
















            This should solve the error, however I don't believe that the program will function correctly. Just looking at roll(), you can see that the random value generated is never actually used.
            – Matt
            Nov 11 at 6:39




            This should solve the error, however I don't believe that the program will function correctly. Just looking at roll(), you can see that the random value generated is never actually used.
            – Matt
            Nov 11 at 6:39












            Yea, that confused me. When I was looking at the code, I guessed that was a typo since that parameter was never used whenever he called roll()
            – Kyle Henry
            Nov 11 at 6:42





            Yea, that confused me. When I was looking at the code, I guessed that was a typo since that parameter was never used whenever he called roll()
            – Kyle Henry
            Nov 11 at 6:42


















            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53246332%2fusing-a-class-to-randomize-dice-rolls%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Top Tejano songwriter Luis Silva dead of heart attack at 64

            政党

            天津地下鉄3号線