package formula;


/**
  The superclass of all named objects in the package.
*/
public abstract class Named implements Comparable<Named> {
  String name;
  public Named(String _name) {  name = _name;  }
  /**
    Compares two named objects for equality, by name.
    @param _b The other object.
    @return true iff this objects's name is the same as the other's.
    @throws ClassCastException If the other object is not also a named object.
  */
  public boolean equals(Object _b) {
    Named b = (Named) _b;
    return name.equals(b.name);
  }
  /**
    Compares two named objects for order, by name.
    @param _b The other object.
    @return -1, 0, or 1 iff this object's name is 
      less than, the same as, or greater than the other's.
    @throws ClassCastException If the other object is not also a named object.
  */
  public int compareTo(Named _b) {
    Named b = (Named) _b;
    return name.compareTo(b.name);
  }
}

