// Start a program where user has to select which option to run // string key - option that user has to select // WhoAmI function - writes on a console Name of the object and EarSize // SpeakTo function - just an example how ".this" operation works in C# // Swap - do swap of two objects // HearMessage - presents a mesage from an object to another Elephant object public static void StartElephantProgram(Elephant first, Elephant second) { string key; Console.WriteLine("Press 1 for Lloyd, 2 for Lucinda, 3 to swap"); key = Console.ReadLine(); if (key == "1") { first.WhoAmI(); } else if (key == "2") { second.WhoAmI(); } else if (key == "4") { first.SpeakTo(second, "Hi " + second.Name); } else { first.Swap(first, second); } }
public void Swap(Elephant first, Elephant second) { Elephant backToNormal; backToNormal = first; first = second; second = backToNormal; second.WhoAmI(); first.WhoAmI(); }