Repository navigation
Expand file tree
/
Copy pathProgram.cs
More file actions
48 lines (40 loc) · 1.33 KB
/
Copy pathProgram.cs
File metadata and controls
48 lines (40 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Dice
{
class Program
{
private const int MIN_DICE_ROLL = 1;
private const int MAX_DICE_ROLL = 6;
private const int TOTAL_ROLLS = 50;
static void Main(string[] args)
{
var random = new Random();
var list1 = RollDice(TOTAL_ROLLS, random);
var list2 = RollDice(TOTAL_ROLLS, random);
var compare = list1.Except(list2);
foreach (var rollTotal in compare)
{
Console.WriteLine(string.Format("Roll Total: {0}", rollTotal));
}
Console.WriteLine(string.Format("There were {0} different rolls.", compare.Count()));
Console.ReadKey();
}
private static List<int> RollDice(int totalRolls, Random randomGenerator)
{
var rollTotal = new List<int>();
for (int index = 0; index < totalRolls; index++)
{
rollTotal.Add(RollDice(randomGenerator) + RollDice(randomGenerator));
}
return rollTotal;
}
private static int RollDice(Random randomGenerator)
{
return randomGenerator.Next(MIN_DICE_ROLL, MAX_DICE_ROLL + 1);
}
}
}