c# - How to let the user create many dice? -
so right now, code can let 2 dice ten times, if wanted user enter number of dice, how do that?
static void main(string[] args) { random numgen = new random(); int dice1 = 0; int dice2 = 1; (int roll = 0; roll <=10; roll++) { dice1 = numgen.next(1,7); dice2 = numgen.next(1,7); console.writeline(dice1 + "\t" + dice2); } console.readline(); }
since doesn't seem need save of dice rolls, rather output them screen omit dice ints.
public void rolldice(int numberofdice) { random numgen = new random(); (int roll = 0; roll <= 10; roll++) { (int = 0; < numberofdice; i++) { console.writeline(numgen.next(1, 7) + "\t" + numgen.next(1, 7)); } } console.readline(); }
Comments
Post a Comment