public override bool Equals(Object o) { if (this == o) { return(true); } if ((o == null) || (this.GetType() != o.GetType())) { return(false); } BinarySentence bs = (BinarySentence)o; return((bs.getOperator().Equals(getOperator())) && (bs.getFirst().Equals(first)) && (bs.getSecond() .Equals(second))); }
public static Sentence chainWith(string connector, ArrayList sentences) { if (sentences.Count == 0) { return null; } else if (sentences.Count == 1) { return (Sentence) sentences[0]; } else { Sentence soFar = (Sentence) sentences[0]; for (int i = 1; i < sentences.Count; i++) { Sentence next = (Sentence) sentences[i]; soFar = new BinarySentence(connector, soFar, next); } return soFar; } }
public virtual Object visitBinarySentence(BinarySentence bs, Object arg) { Hashtable s =(Hashtable)arg; Hashtable termunion = new SetOps().union((Hashtable)bs.getFirst().accept(this,arg),(Hashtable)bs.getSecond().accept(this,arg)); return new SetOps().union(s,termunion); }
public Object visitBinarySentence(BinarySentence bs, Object arg) { Object firstValue = bs.getFirst().accept(this,null); Object secondValue = bs.getSecond().accept(this,null); if ((firstValue == null) || (secondValue == null)) { //strictly not // true for or/and // -FIX later return null; } else { string oper = bs.getOperator(); if (oper.Equals("AND")) { return evaluateAnd((bool) firstValue, (bool) secondValue); } if (oper.Equals("OR")) { return evaluateOr((bool) firstValue, (bool) secondValue); } if (oper.Equals("=>")) { return evaluateImplied((bool) firstValue, (bool) secondValue); } if (oper.Equals("<=>")) { return evaluateBiConditional((bool) firstValue, (bool) secondValue); } return null; } }