import java.util.*;
import java.lang.*;
import java.io.*;
// The main method must be in a class named "Main".
class Main {
public static void main(String[] args) {
Dog dog = new Dog();
Cat cat = new Cat();
dog.eat();
cat.eat();
Owner owner = new Owner();
owner.feed(dog);
owner.feed(cat);
}
}
interface IAnimal {
public void eat();
}
class Dog implements IAnimal {
public void eat() {
System.out.println("Dog eats.");
}
}
class Cat implements IAnimal {
public void eat() {
System.out.println("Cat eats.");
}
}
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: