using System;
public class Program
{
public static void Main(string[] args)
{
var dog = new Dog();
var cat = new Cat();
dog.eat();
cat.eat();
var owner = new Owner();
owner.feed(dog);
owner.feed(cat);
}
}
public interface IAnimal
{
void eat();
}
public class Dog : IAnimal
{
public void eat()
{
Console.WriteLine("Dog eats.");
}
}
public class Cat : IAnimal
{
public void eat()
{
Console.WriteLine("Cat eats.");
}
}
public class Owner
{
public void feed(IAnimal animal)
{
animal.eat();
}
}
To embed this project on your website, copy the following code and paste it into your website's HTML: