public static void use( Robot obj) { Console.WriteLine("**** Start use ****"); Robot copy = null; obj.number_of_sensors = 2; if (obj is Robot) { Console.WriteLine("Cloning object"); } copy = obj.clone(); Console.WriteLine($"Original object value = {obj.number_of_sensors}"); Console.WriteLine($"Copy object value = {copy.number_of_sensors}"); Console.WriteLine("Change copy object"); copy.number_of_sensors = 15; Console.WriteLine($"Original object value = {obj.number_of_sensors}"); Console.WriteLine($"Copy object value = {copy.number_of_sensors}"); Console.WriteLine("**** End use ****"); }
private void deep_copy(Robot original) { this.number_of_sensors = original.number_of_sensors; }
public Robot (Robot original) { Console.WriteLine ("Robot Copy Constructor"); this.deep_copy(original); }