//behavior // solves triples problem (simplified) from page 322 of my book Company { traversal allProducers( SameLocationV slv, CustomerTV ctv, ProducerTV ptv ){ to Producer;} // allProducers // Host/Visitor interaction // slv ctv ptv // ----------------------------------------- // before ?,!ctv //Customer //Item // after ?ctv,?ptv // before ?,!ptv //Producer // ----------------------------------------- //Legend: // ? read from host // ?ctv read from visitor ctv // ! write to host // !ctv write to visitor ctv (@ // finds items for which customer and producer live // in the same location void same_location() { CustomerTV ctv = new CustomerTV(); ProducerTV ptv = new ProducerTV(); SameLocationV slv = new SameLocationV(ctv,ptv); this.allProducers(slv, ctv, ptv); } @) } // customer transportation visitor CustomerTV { before Customer (@ name = host.get_name(); location = host.get_location(); @) } // producer transportation visitor ProducerTV { before Producer (@ name = host.get_name(); location = host.get_location(); @) } SameLocationV { after Item (@ if (ctv.get_location().equals(ptv.get_location())) { System.out.println( " ctv= " + ctv.get_name() + " ptv= " + ptv.get_name() + " current item= " + host.get_name()); } @) } Main { (@ static public void main(String args[]) throws Exception { Runtime rt = Runtime.getRuntime(); rt.traceMethodCalls(true); Company a = Company.parse(System.in); a.same_location(); System.out.println("done "); } @) }