The goal of this lab period is to get you started on the current assignment, give you an introduction to an Abstract class and go over how to remove an item from a Linked List.
Documentation for Java 1.6 is located at: Java 1.6 SE API
Update your Linked List class to have a remove method. It should
remove the Node containing the given object from the list. Put a test
of your remove method in the main function of your LinkedList class.
public void remove(T thing) - removes the Node containing thing from the list.
- How would you write the remove method for your LLIterator? What information would need to be stored in the LLIterator class?
Create an abstract class Animal.
public abstract class Animal
It should have a field for the animal's name and accessors to get and set the value. Give the class an abstract method Speak that returns a string representation of the sound the animal makes.
public abstract String speak()
- Create several derived classes of the Animal parent class that each implement the speak method. In the derived classes, the speak method will not be abstract.
- Create a test class with a main function that creates an ArrayList<Animal>. Then add different types of animals to the list. Finally, go through the list and have each animal speak.
Once you are comfortable with the above tasks, go on to the assignment.