Skip to content

Instantly share code, notes, and snippets.

@maxpowa
Created March 6, 2014 23:29
Show Gist options
  • Save maxpowa/9401938 to your computer and use it in GitHub Desktop.
Save maxpowa/9401938 to your computer and use it in GitHub Desktop.
Dice!
using System;
public enum Die { one = 1, two, three, four, five, six }
public struct Dice
{
static Random rand = new Random();
Die firstDie;
Die secondDie;
public Dice()
{
this.firstDie = Die.one;
this.secondDie = Die.one;
}
public Dice(bool random = false)
{
if (random)
{
this.firstDie = (Die)rand.Next(1, 7);
this.secondDie = (Die)rand.Next(1, 7);
}
else
{
this.firstDie = Die.one;
this.secondDie = Die.one;
}
}
public override string ToString()
{
return String.Format("{0} ({1} and {2})", (int)this.firstDie + (int)this.secondDie, this.firstDie, this.secondDie);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment