// @(#)$Id: FSEntityProblem.scala,v 1.1 2005/10/28 09:03:35 leavens Exp leavens $
package scalahw;

trait FSEntityProblem {

  type EName = String;
  type Contents = String;
  type Path = List[EName];
  type Map[A,B] = scala.collection.mutable.Map[A,B];

  /** File system entities */
  trait FSEntity {
    /** Says whether this FSEntity is okay. */
    def okFSEntity: Boolean;
  }

  /** Things with a fetch method (directories). */
  trait Fetchable {
    /** Fetch the FSEntity along p from this,
     * or throw an exception if can't do that. */
    def fetch(p: Path): FSEntity;
  }

  // You have to implement the above two methods
  // for each of the following two subtypes of FSEntity.
  // Your definition should also produce the functions required below.
  // Hint: Use case classes.

  /** Files, with contents c. */
  type File <: FSEntity;
  def File(c: Contents): File;

  /** Directories, with map from names to FSEntities m. */
  type Dir <: FSEntity with Fetchable;
  def Dir(m: Map[EName, FSEntity]): Dir;
}
