private static void WriteSound(IMakeSounds soundMaker, Func <IMakeSounds, string> sound) { if (soundMaker != null) { Console.WriteLine($"*** {sound(soundMaker)} ***"); } }
private static void MakeSounds(IMakeSounds soundMaker) { Console.WriteLine($"A surprised {soundMaker.GetType().Name} makes the sound {soundMaker.Surprise()}"); Console.WriteLine($"A contented {soundMaker.GetType().Name} makes the sound {soundMaker.Contentment()}"); }