// joi/4/textfiles/Directory.java                         
//                                                            
//                                                            
// Copyright 2003 Ethan Bolker and Bill Campbell                         
                                                            
// This draft contains just stubs for the methods.
// You can invoke them all, but none will do anything.

/** 
 * Directory of TextFiles.
 *
 * @version 4
 */

public class Directory 
{
    /** 
     * Construct a Directory.
     */

    public Directory( ) 
    {
    }

    /**
     * The size of a directory is the number of TextFiles it contains.
     *
     * @return the number of TextFiles.
     */

    public int getSize()
    {
        return 0; 
    }

    /**
     * Add a TextFile to this Directory. Overwrite if a TextFile
     * of that name already exists.
     *
     * @param name the name under which this TextFile is added.
     * @param afile the TextFile to add.
     */

    public void addTextFile(String name, TextFile afile) 
    {
    }

    /**
     * Get a TextFile in this Directory, by name .
     *
     * @param filename the name of the TextFile to find.
     * @return the TextFile found, null if none.
     */

    public TextFile retrieveTextFile( String filename ) 
    {
        return null;
    }

    /**
     * Get the contents of this Directory as an array of 
     * the file names, each of which is a String.
     *
     * @return the array of names.
     */

    public String[] getFileNames()
    {
        // pseudocode for an implementation:
        // declare an array of String
        // create that array with as many spaces as there
        //   are TextFile's in this Directory
        // loop through the keys of the TreeMap of TextFiles,
        // adding each String key to the array
        // return the array

        // the next line is there because we have to return
        // _something_ in order to satisfy the compiler
        return new String[0]; 
    }

    /**
     *  main, for unit testing.
     *
     * The command
     * <pre>
     *   java Directory
     * </pre>
     * should produce output
     * <pre>
     * bill     17      Sun Jan 06 19:40:13 EST 2003    diary
     * eb       12      Sun Jan 06 19:40:13 EST 2003    greeting
     * </pre>
     * (with current dates, of course).
     */

    public static void main( String[] args ) 
    {
        Directory dir = new Directory();
        dir.addTextFile("greeting", new TextFile("eb", "Hello, world")); 
        dir.addTextFile("diary", new TextFile("bill", "Writing Directory")); 
        // now list TextFiles in dir to get output specified
    }
}

