public override bool Equals(object o) { if (this == o) { return(true); } if ((o == null) || (this.GetType() != o.GetType())) { return(false); } bool result = false; ComplexSentence other = (ComplexSentence)o; if (other.GetHashCode() == this.GetHashCode()) { if (other.getConnective().Equals(this.getConnective()) && other.getNumberSimplerSentences() == this .getNumberSimplerSentences()) { // connective and # of simpler sentences match // assume match and then test each simpler sentence result = true; for (int i = 0; i < this.getNumberSimplerSentences(); ++i) { if (!other.getSimplerSentence(i).Equals( this.getSimplerSentence(i))) { result = false; break; } } } } return(result); }