using System;
namespace RockPaperScissors
{
public sealed class ComputerPlayer : Player
{
public ComputerPlayer(string name) : base(name) { }
public override void MakeMove()
{
Move = RandomMoveGenerator.MakeRandomMoveGenerateRandomMove();
Console.WriteLine($"{this.Name} made a {this.Move}");
}
}
}
using System;
using System.Linq;
namespace RockPaperScissors
{
public static class RandomMoveGenerator
{
private readonly static Random random = new Random();
private static readonly Move[] moves = Enum.GetValues(typeof(Move))
.Cast<Move>()
.ToArray();
public static Move MakeRandomMoveGenerateRandomMove() => moves[random.Next(moves.Length)];
}
}