public void CreateTamagochi(TamagochiType type, string name) { if (_tamagochi == null) { _tamagochi = TamagochiCreator.CreateTamagochi(type); _tamagochi.Name = name; } else { throw new InvalidOperationException(); } }
public static Tamagochi CreateTamagochi(TamagochiType type) { switch (type) { case TamagochiType.Cat: return(new Cat()); case TamagochiType.Dog: return(new Dog()); default: throw new ArgumentOutOfRangeException(); } }