/** * This class counts the number of variables appearing in the given formula. * */ class WeightedVariableCounter extends VariableCounter { Float apply(Weight w) { System.out.println(" weight ====================" + w.get_v()); return new Float(w.get_v());} Float combine(Constraint c, Float w, Float variable_count) { System.out.println(" weight ====================" + w + " var count " + variable_count); return variable_count*w; } static Float countWeightedVariables(Object o){ return traverse(o, new WeightedVariableCounter()); } }