001 /* 002 * Created on Sep 15, 2003 by Ravi Mohan 003 * 004 */ 005 package aima.logic.propositional.parsing.ast; 006 007 import aima.logic.propositional.parsing.PLVisitor; 008 import aima.logic.propositional.parsing.ast.Sentence; 009 010 /** 011 * @author Ravi Mohan 012 * 013 */ 014 015 public class UnarySentence extends ComplexSentence { 016 private Sentence negated; 017 018 public Sentence getNegated() { 019 return negated; 020 } 021 022 public UnarySentence(Sentence negated) { 023 this.negated = negated; 024 } 025 026 @Override 027 public boolean equals(Object o) { 028 029 if (this == o) { 030 return true; 031 } 032 if ((o == null) || (this.getClass() != o.getClass())) { 033 return false; 034 } 035 UnarySentence ns = (UnarySentence) o; 036 return (ns.negated.equals(negated)); 037 038 } 039 040 @Override 041 public int hashCode() { 042 int result = 17; 043 result = 37 * result + negated.hashCode(); 044 return result; 045 } 046 047 @Override 048 public String toString() { 049 return " ( NOT " + negated.toString() + " ) "; 050 } 051 052 @Override 053 public Object accept(PLVisitor plv, Object arg) { 054 return plv.visitNotSentence(this, arg); 055 } 056 }