import edu.neu.ccs.demeter.dj.*; // import com.objectspace.jgl.*; // import com.objectspace.jgl.algorithms.*; import java.util.*; class Main { public static void main(String[] args) { ClassGraph cg = new ClassGraph(); // constructed from *.java System.out.println(cg.getVersion() + " = version"); // 5 people MyVector persons = new MyVector(); persons.addElement(new Person()); persons.addElement(new Person()); persons.addElement(new Person()); persons.addElement(new Person()); persons.addElement(new Person()); BusStop aBusStop = new BusStop(persons); MyVector busStops = new MyVector(); // 10 people busStops.addElement(aBusStop); busStops.addElement(aBusStop); Village aVillage = new Village(busStops); MyVector villages = new MyVector(); // 20 people villages.addElement(aVillage); villages.addElement(aVillage); MyVector buses = new MyVector(); buses.addElement(persons); buses.addElement(persons); BusRoute aBusRoute = new BusRoute(buses, villages); Strategy sg = new Strategy("from BusRoute through BusStop to Person"); TraversalGraph tg = new TraversalGraph(sg, cg); Integer result = (Integer) tg.traverse(aBusRoute, new MyVisitor()); int r = result.intValue(); if (r==20) {System.out.println("SUCCESS");} else {System.out.println("FAILURE");}; System.out.println(" number of waiting persons = " + result); System.out.println ("Traversal Graph for from BusRoute through BusStop to Person"); System.out.println(tg); //InputIterator beginDs = tg.start(aBusRoute); //InputIterator endDs = tg.finish(aBusRoute); //Printing.println(beginDs, endDs); ObjectGraph og = new ObjectGraph(aBusRoute,cg); int res2 = aBusRoute.count2(new ObjectGraphSlice(og, "from BusRoute through BusStop to Person")); System.out.println(" number of waiting persons = " + res2); int res3 = aBusRoute.count3(new ObjectGraphSlice(og, "from BusRoute through BusStop to Person")); System.out.println(" number of waiting persons = " + res3); System.out.println(" Print waiting people"); List e = cg.asList(aBusRoute,"from BusRoute through BusStop to Person"); Iterator i = e.iterator(); while (i.hasNext()) System.out.println(i.next()); } }