import java.util.*;

        // Simple definition of the Ship class with position,
        // speed and course information.
        // The Ship maintains a log of its position after each
        // move using an inner class ShipLog object.
public class LoggingShip extends SimpleShip {
    public LoggingShip(){
        // Log the ship's initial details.
        getLogger().log();
    }

        // Extend move so that it records the new position.
    public void move(){
        super.move();
        getLogger().log();
    }

        // Return whatever information the logger has collected.
    public Iterator getLog(){
        return getLogger().getLog().iterator();
    }

        // Delegate the role of logging information to
        // a ShipLog object.
    protected class ShipLog {
        protected void log(){
            // Get the enclosing ship's position.
            Position p = new Position(getX(),getY());
            // Add it to the log.
            getLog().add(p);
        }

        protected LinkedList getLog(){
            return positionLog;
        }

        private LinkedList positionLog = new LinkedList();
    }

    protected ShipLog getLogger(){
        return logger;
    }

    private final ShipLog logger = new ShipLog();
}
