Cover Data Structures and Algorithms with Object-Oriented Design Patterns in Java
next up previous contents index

Projects

  1.   Design and implement suitable wrapper classes that implement the Comparable interface for the Java primitive types boolean, byte, short, long, float, and void.
  2. Using visitors, devise implementations for the isMember and find methods of the AbstractSearchableContainer class declared in Program gif.
  3. Using enumerations, devise implementations for the isMember and find methods of the AbstractSearchableContainer class declared in Program gif.
  4. Devise a scheme using visitors whereby all of the objects contained in one searchable container can be removed from it and transfered to another container.
  5.   A bag  is a simple container that can hold a collection of objects. Design and implement a concrete class called Bag that extends the AbstractSearchableContainer class defined in Program gif. Use the Array class given in Chapter gif to keep track of the contents of the bag.
  6. Repeat Project gif, this time using the LinkedList class given in Chapter gif.
  7. In C++ it is common to use an iterator  as the means to iterate through the objects in a container. In Java we can define an iterator like this:
    public interface Iterator
    {
        void init ();
        boolean test ();
        void inc ();
        Object current ();
    }
    Given an iterator i from some container c, the contents of c can be printed like this:
    for (i.init(); i.test(); i.inc())
        System.out.println (i.current());
    Devise a wrapper class to encapsulate an enumeration and provide the functionality of an iterator.


next up previous contents index

Bruno Copyright © 1998 by Bruno R. Preiss, P.Eng. All rights reserved.