|
|
@ -492,11 +492,13 @@ public class TestEdible {
|
|
|
|
public static void main(String[] args) {
|
|
|
|
public static void main(String[] args) {
|
|
|
|
Object[] objects = { new Tiger(), new Chicken(), new Apple() };
|
|
|
|
Object[] objects = { new Tiger(), new Chicken(), new Apple() };
|
|
|
|
for (int i = 0; i < objects.length; i++) {
|
|
|
|
for (int i = 0; i < objects.length; i++) {
|
|
|
|
if (objects[i] instanceof Edible)
|
|
|
|
if (objects[i] instanceof Edible) {
|
|
|
|
System.out.println(((Edible) objects[i]).howToEat());
|
|
|
|
Edible e = (Edible) objects[i];
|
|
|
|
|
|
|
|
System.out.println(e.howToEat());
|
|
|
|
|
|
|
|
}
|
|
|
|
if (objects[i] instanceof Animal) {
|
|
|
|
if (objects[i] instanceof Animal) {
|
|
|
|
System.out.println(((Animal) objects[i]).sound());
|
|
|
|
Animal a = (Animal) objects[i];
|
|
|
|
|
|
|
|
System.out.println(a.sound());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|