Files
basic-computer-games/16_Bug/csharp/Parts/Neck.cs
2022-07-12 07:41:45 +10:00

24 lines
576 B
C#

using BugGame.Resources;
namespace BugGame.Parts;
internal class Neck : ParentPart
{
private Head _head = new();
public Neck()
: base(Message.NeckAdded, Message.NeckNotNeeded)
{
}
public override bool IsComplete => _head.IsComplete;
protected override bool TryAddCore(IPart part, out Message message)
=> part switch
{
Head => _head.TryAdd(out message),
Feeler => _head.TryAdd(part, out message),
_ => throw new NotSupportedException($"Can't add a {part.Name} to a {Name}.")
};
}