using System.Collections.Generic;
public string Name { get; private set; }
public Robot() => Reset();
var newName = NameGenerator.Generate();
NameGenerator.FreeUp(Name);
public static class NameGenerator
private const string AllowedCharacters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
private static readonly Random _random = new Random();
private static HashSet<string> _namesInUse = new HashSet<string>();
public static string Generate()
name = $"{GetRandomCharacter()}{GetRandomCharacter()}{GetThreeRandomDigits()}";
while (_namesInUse.Contains(name));
public static void FreeUp(string name)
_namesInUse.Remove(name);
private static char GetRandomCharacter() => AllowedCharacters[_random.Next(0, AllowedCharacters.Length)];
private static string GetThreeRandomDigits() => _random.Next(0, 1000).ToString("D3");