title: How to add properties to ArrayLists that include inheritance?
body: <p>I'm doing an assignment on inheritance and I have so far created a superclass a subclass. Within these classes, there are methods that have been added to define information such as an animal's name or age. Now I have been asked to do the following:</p>
  
  <ul>
  <li>Create a Demo class with a main method that creates an ArrayList of Animal objects. Fill the list with different animals, also with different names and ages.</li>
  </ul>
  
  <p>I'm completely confused by this. If I try to create animals within my new ArrayList it tells me that the Animal class is abstract and cannot be instantiated. Here is the contents of the relevant classes:</p>
  
  <p><strong>Animal class (super class)</strong></p>
  
  <pre><code>abstract public class Animal 
  {
  
      int age;
      String name;
      String noise;
  
  Animal(String name, int age)   
  {
      this.age = age;
      this.name = name;
  } 
  
  Animal()
  {
  
    this("newborn", 0);
  }
  
  abstract public void makeNoise();
  
  public String getName() {
          return name;
      }
    public int getAge()
      {
          return age;
      }
  
      public void setName(String newName) {
          name = newName;
      }
  
  abstract public Food eat(Food x) throws Exception;
  
  abstract public void eat(Food food, int count) throws Exception;
  
  
  }
  </code></pre>
  
  <p><strong>Wolf class (sub class)</strong></p>
  
  <pre><code>import java.util.ArrayList;
  
  public class Wolf extends Carnivore
  {
  
              ArrayList&lt;Food&gt; foodGroup = new ArrayList&lt;&gt;();
  String name;
  int age;
  
  Wolf(String name, int age)   
  {  
      this.name = name;
      this.age = age;
  }
  Wolf()
  {
    super();
  }
      public void makeNoise()  
      {
          noise = "Woof!";
      }
      public String getNoise()  
      {
          return noise;
      }
  
      public Food eat(Food x) throws Exception
      { 
          if (x instanceof Meat) {
                  return x;
              } else {
                 throw new Exception("Carnivores only eat meat!");
              }
      }
  public void eat(Food food, int count) {
      while (count &gt; 0) {
          addFood(food);
          count--;
      }
  }
  
  
  public void addFood(Food inFood)
  {
    foodGroup.add(inFood);
  }
  }
  </code></pre>
  
  <p><strong>Demo class</strong></p>
  
  <pre><code>import java.util.ArrayList;
  
  public class Demo {
  
      public static void main(String[] args) 
      {
                      ArrayList&lt;Animal&gt; animalGroup = new ArrayList&lt;&gt;();
       //Add new Animals with properties such as name and age?           
       Animal wolf1 = new Wolf();
  
      addAnimal(new Wolf("lnb1g16", 6));
  
      }
  
      public static void addAnimal(Animal inAnimal)
  {
      animalGroup.add(inAnimal);
  }
  
  }
  </code></pre>
  
  <p>Apparently I'm suppose to create an array of Animals in the Demo class based off of these prior classes? I don't understand how this would be done and why I need to create a another main method either. Any help on how I would write the Demo class would be much appreciated as I'm confused by what I have been asked to do, thanks. </p>