/home/caleb/ASDV-Java/Semester 2/Assignments/lab8_CalebFontenot/src/main/java/com/calebfontenot/lab8_calebfontenot/TestEdible.java
/*
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
 */
package com.calebfontenot.lab8_calebfontenot;

import java.util.ArrayList;

/**
 *
 * @author caleb
 */


public class TestEdible {
    public static void testWithArrayList() {
        ArrayList<Edible> edible = new ArrayList();
        
        edible.add(new Chicken());
        edible.add(new Apple());
        edible.add(new Orange());
        edible.add(new Duck());
        edible.add(new Brocoli());

        for (Edible eat: edible) {
            System.out.println(eat.howToEat());
        }
    }
    public static void testWithArrayOfInterfaces() {
        Edible[] edible = {
        new Chicken(), new Apple(), new Orange(), new Duck(), new Brocoli()
    };
        for (int i = 0; i < edible.length; ++i) {
            System.out.println(edible[i].howToEat());
        }
    }
    public static void testWithArrayOfObjects() {
        Object[] objects = {
            new Tiger(), new Chicken(), new Apple(), new Duck(), new Brocoli()
        };
        for (int i = 0; i < objects.length; ++i) {
            if (objects[i] instanceof Edible) {
                System.out.println(((Edible) objects[i]).howToEat());
            }
            if (objects[i] instanceof Animal) {
                System.out.println(((Animal) objects[i]).sound());
            }
        }
    }
    public static void main(String[] args)
    {
        testWithArrayOfObjects();
        System.out.println("-------------------");
        testWithArrayOfInterfaces();
        System.out.println("------------------ ");
        testWithArrayList();
    }
}