/*
 * This program defines classes representing pets using inheritance.
 * It also demonstrates the use of polymorphism in Java for calling
 * methods and storing object references in arrays.
 * Nadeem Abdul Hamid - CSC120 - Fall 2004 - Berry College
 * See lecture unit 11 slides
 */

public class SecondPetProgram {

    public static void main(String[] args) {
        Pet[] pets = new Pet[2];
        pets[0] = new Dog("Rufus", 4);
        pets[1] = new Cat("Panther", 2);
        
        for (int i = 0; i < pets.length; i++) {
            pets[i].makeSound();
            System.out.println(pets[i].getName() 
                                + " likes " + pets[i].getFood());
        }
    }
    
    /*    
    public static void main(String[] args) {
        Pet doggy = new Dog("Rufus", 4);
        Pet kitty = new Cat("Panther", 2);
        
        doggy.makeSound();
        System.out.println(doggy.getName() 
                            + " likes " + doggy.getFood());
        kitty.makeSound();
        System.out.println(kitty.getName() 
                            + " likes " + kitty.getFood());
    }
    */


    /*
    public static void main(String[] args) {
        Dog doggy = new Dog("Rufus", 4);
        Cat kitty = new Cat("Panther", 2);
        
        doggy.makeSound();
        System.out.println(doggy.getName() 
                            + " likes " + doggy.getFood());
        kitty.makeSound();
        System.out.println(kitty.getName() 
                            + " likes " + kitty.getFood());
    }
    */

}


class Dog extends Pet {
    public Dog(String n, int a) {
        name = n;
        age = a;
        maxAge = 12;
        sound = "woof woof";
        food = "doggy bites";
        
        System.out.println(name + " is ready to go for a walk!");
    }    
}

class Cat extends Pet {
    public Cat(String n, int a) {
        name = n;
        age = a;
        maxAge = 10;
        sound = "meow meow";
        food = "kitty food";

        System.out.println(name + " is ready to catch some mice!");
    }
}


    // color
    // tail

class Pet {

    protected String name;
    protected int age;
    protected int maxAge;
    protected String sound;
    protected String food;
    
    public String getName() { return name; }
    public int    getAge()  { return age; }
    public int    getMaxAge() { return maxAge; }
    public String getFood() { return food; }
    
    public void makeSound() { 
        System.out.println(sound);
    }

}