Main { {{ public static void main(String args[]) throws Exception { Formula csp = Formula.parse(System.in); System.out.println("The given input is:"); csp.print(); Traversal travNumLit = new Traversal(new LitCounter()); // the second argument to traverse is tricky // it is needed becuase we pass down the weight from ConcreteClause to literals System.out.println("The number of literals is:" + travNumLit.traverse(csp)); // + travNumLit.traverse(csp, 0)); Traversal travWeight = new Traversal(new TotalWeightCounter()); System.out.println("The total weight of this formula is:" + travWeight.traverse(csp)); System.out.println("================================================"); } }} } Formula { void print() to * (PrintVisitor); void display() to * (DisplayVisitor); } LiteralList { void print() to * (PrintVisitor); }