package ContainerExample; import FVisitor.CompReceiver; import FVisitor.ConditionalComp; import FVisitor.FVisitor; import FVisitor.ThreadedComp; import FVisitor.Wrapper; /* * Test Classes for Dynamic Traversals */ public class CompTest{ public static void main(String[] args) { // Object Graph... Container con; con = new Container(18, new Item[]{ new Element(4), new Element(4), new Element(1), new Element(2), new Container(8, new Item[]{new Element(4), new Element(6)}), new Element(1), new Container(5, new Item[]{new Element(6), new Element(1)})}); try{ //ConditionalComp, Increment> // module = new ConditionalComp(new ThreadedComp(new ElementSum(0), new Overfull(null, false)), new Increment(0)); CheckWrap module = new CheckWrap(); CheckWrap module2 = new PaddedCheckWrap(); module = ((CheckWrap)con.accept(module)); module2 = ((CheckWrap)con.accept(module2)); System.out.println(" ElementSum: Total Weight : " + module.getSum()); System.out.println(" ContCheck: # Violations : " + module.getOverfilled()+"\n"); System.out.println(" ElementSum: Total Weight : " + module2.getSum()); System.out.println(" ContCheck: # Violations : " + module2.getOverfilled()+"\n"); }catch(Exception e){ System.err.println(e); e.printStackTrace(); } } }