Back to slide -- Keyboard shortcut: 'u'  previous -- Keyboard shortcut: 'p'  next -- Keyboard shortcut: 'n'          Die-variants/die-0-0-namespace/die.cs - The class Die in the namespace Game.Lecture 3 - slide 2 : 29
Program 4

using System;

namespace Game {
  public class Die {
    private int numberOfEyes;
    private Random randomNumberSupplier; 
    private const int maxNumberOfEyes = 6;
  
    public Die(){
      randomNumberSupplier = new Random(unchecked((int)DateTime.Now.Ticks));
      numberOfEyes = NewTossHowManyEyes();
    }   
      
    public void Toss(){
      numberOfEyes = NewTossHowManyEyes();
    }
  
    private int NewTossHowManyEyes (){
      return randomNumberSupplier.Next(1,maxNumberOfEyes + 1);
    }
  
    public int NumberOfEyes() {
      return numberOfEyes;
    }
  
    public override String ToString(){
      return String.Format("[{0}]", numberOfEyes);
    }
  }
}