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/AbstractDie.cs

38 lines
812 B

using System;
using System.Collections.Generic;
using System.Linq;
using Model.Dice.Faces;
namespace Model.Dice
{
public abstract class AbstractDie<T> : RandomnessHaver where T : AbstractDieFace
{
protected string Name;
public IEnumerable<T> ListFaces => listFaces;
private readonly List<T> listFaces = new();
protected AbstractDie(string name, params T[] faces)
{
Name = name;
listFaces.AddRange(faces);
}
public string GetName() => Name;
public T GetRandomFace()
{
int faceIndex = rnd.Next(1, ListFaces.Count() + 1);
return ListFaces.ElementAt(faceIndex);
}
public List<T> GetDieFaces()
{
return (List<T>)ListFaces;
}
}
}