Example #1
0
		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 ****");
	
		}
Example #2
0
		private void deep_copy(Robot original)
		{
			this.number_of_sensors = original.number_of_sensors;
		}
Example #3
0
		public Robot (Robot original)
		{
			Console.WriteLine ("Robot Copy Constructor");
			this.deep_copy(original);
		}