mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-22 07:10:42 -08:00
add 00_Alternate_Langage folder and move alternate ports there
This commit is contained in:
20
00_Alternate_Languages/33_Dice/csharp/RollGenerator.cs
Normal file
20
00_Alternate_Languages/33_Dice/csharp/RollGenerator.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace BasicComputerGames.Dice
|
||||
{
|
||||
public class RollGenerator
|
||||
{
|
||||
static Random _rnd = new Random();
|
||||
|
||||
public static void ReseedRNG(int seed) => _rnd = new Random(seed);
|
||||
|
||||
public IEnumerable<(int die1, int die2)> Rolls()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
yield return (_rnd.Next(1, 7), _rnd.Next(1, 7));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user