package hashtable;

/**
 * Title:
 * Description:
 * Copyright:    Copyright (c) 2002
 * Company:
 * @author
 * @version 1.0
 */

public class Key implements HashComparator {

  int x ;
  int y ;

  public Key(int x, int y) {
    this.x = x ;
    this.y = y ;
  }

  public Key() {
    this(0,0) ;
  }

  public boolean isComparable(Object j) {
  try {
    //return Class.forName("hashtable.HashComparator").isInstance(j) ;
    HashComparator hc = (HashComparator) j ;
  } catch ( ClassCastException cce  /* ClassNotFoundException cnfe */
    ) {
    System.out.println("class not found") ;
    return false ;
  }
  return true ;
  }

  public boolean isEqualTo(Object j, Object k) {
    return (((Key)j).x==((Key)k).x) && (((Key)j).y==((Key)k).y)  ;
  }

  public int hashValue(Object j) {
     return ((Key)j).x+((Key)j).y*((Key)j).y ;
  }

}
