//  Data Structures with Java by John R. Hubbard
//  Copyright McGraw-Hill, 2001
//  Problem 3.4 on page 72

public boolean equals(Object object)
{ if (object == this) return true;
  if (object.getClass() != this.getClass()) return false;
  Widget y = (Widget)object;
  Widget t = this;
  while (y != null || t != null)
  { if (y == null || t == null) return false;
    if (y.n != t.n) return false;
    y = y.w;
    t = t.w;
  }
  return true;
}