You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
dice_app/Sources/Model/Dice/Die.cs

28 lines
590 B

using Model.Dice.Faces;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Model.Dice
{
public abstract class Die
{
public IEnumerable<Face> Faces => faces;
protected static readonly Random rnd = new();
private readonly List<Face> faces = new();
protected Die(params Face[] faces)
{
this.faces.AddRange(faces);
}
public virtual Face GetRandomFace()
{
int faceIndex = rnd.Next(0, Faces.Count());
return Faces.ElementAt(faceIndex);
}
}
}