using System;
public interface IAnimal
{
void ChangeName(string newName);
}
public class Animal : IAnimal
protected string _name { get; set; }
public string Name { get { return _name; } }
public Animal()
_name = this.GetType().Name;
public virtual void ChangeName(string newName)
_name = newName;
public class Bear : Animal
public override void ChangeName(string newName)
_name = newName + " the Bear";
public void Attack(Animal animal)
Console.WriteLine(Name + " has attacked " + animal.Name + "!");
public class Duck : Animal
public void Fly()
Console.WriteLine(Name + " has started flying!");
public class Program
public static void Main(string[] args)
var bear = new Bear();
var duck = new Duck();
Console.WriteLine("bear: \""+bear.Name+"\"");
Console.WriteLine("duck: \""+duck.Name+"\"");
bear.Attack(duck);
bear.ChangeName("Bob");
duck.ChangeName("Deidre");
duck.Fly();
Operation failed. Please try again or report this to support.