What we want is: from University through e:Employee to ParkingSticker void before(ParkingSticker p){ "retrieve most recent e" and print it; } From avi@ccs.neu.edu Thu Dec 14 18:01:46 2000 X-UIDL: d7fa53baa868d45ef20ef305151f05a8 Return-Path: Received: from tisch.mail.mindspring.net (tisch.mail.mindspring.net [207.69.200.157]) by amber.ccs.neu.edu (8.10.0.Beta10/8.10.0.Beta10) with ESMTP id eBEN1jX29354 for ; Thu, 14 Dec 2000 18:01:46 -0500 (EST) Received: from aviran (user-2ivef3o.dsl.mindspring.com [165.247.60.120]) by tisch.mail.mindspring.net (8.9.3/8.8.5) with SMTP id SAA12359 for ; Thu, 14 Dec 2000 18:01:44 -0500 (EST) From: "Aviran Levy" To: "Karl J. Lieberherr" Subject: RE: COM3360 Project Date: Thu, 14 Dec 2000 18:02:12 +0200 Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_0000_01C065F7.FC153670" X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) In-Reply-To: <004801c065e7$613b4960$cd760a81@ccs.neu.edu> X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 Importance: Normal Status: RO Content-Length: 5487 This is a multi-part message in MIME format. ------=_NextPart_000_0000_01C065F7.FC153670 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Ok, I'll come to your office. Sorry for not coming to the last lecture tonight. My schedule is becoming more tight then before. I want to attached the java files of my project so we can look at them tomorrow. Thanks -- Avi -----Original Message----- From: Karl J. Lieberherr [mailto:lieberherr@ccs.neu.edu] Sent: Thu, December 14, 2000 6:03 PM To: Aviran Levy; Karl Lieberherr Subject: Re: COM3360 Project Can we meet on Friday at 10 am? -- Karl ----- Original Message ----- From: Aviran Levy To: Karl Lieberherr Sent: Wednesday, December 13, 2000 3:53 PM Subject: COM3360 Project > Hi, > > I would like to meet you and show you my code for the extended visitor. > Unfortunately tomorrow I'm not available until 9:00 in the evening (I have a > meeting just after the first half of the lecture). can we meet afterwards? I > can also meet you on Friday all day. > > Thanks > -- Avi > ------=_NextPart_000_0000_01C065F7.FC153670 Content-Type: java/*; name="Employee.java" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="Employee.java" public class Employee { private ParkingSticker parkingSticker; String Name; public Employee(ParkingSticker ps , String name) { parkingSticker = ps; Name = name; } public Employee(String name) { Name = name; } } ------=_NextPart_000_0000_01C065F7.FC153670 Content-Type: java/*; name="Main.java" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="Main.java" import java.util.*; import edu.neu.ccs.demeter.dj.*; public class Main=20 { public static void main(String args[])=20 { =09 List employees =3D new LinkedList(); Employee m =3D new Employee("test"); employees.add(new Employee(new ParkingSticker(1000), "Emp1")); employees.add(new Employee(new ParkingSticker(2000), "Emp2")); employees.add(new Employee(new ParkingSticker(3000), "Emp3")); employees.add(new Employee(new ParkingSticker(4000), "Emp4")); employees.add(new Employee("Emp5")); employees.add(new Employee("Emp6")); =09 University u =3D new University(new Employee(new ParkingSticker(1111), = "Manager"),employees); =09 ClassGraph cg =3D new ClassGraph(); =09 TraversalGraph tg =3D new TraversalGraph("from University to = ParkingSticker" , cg); =09 tg.traverse(u, new tvisitor() { void before(ParkingSticker p) { =09 System.out.println(getNumObj("ParkingSticker")); } }); =09 //Visitor m =3D new MyVisitor(); //System.out.println(m); =09 } } ------=_NextPart_000_0000_01C065F7.FC153670 Content-Type: java/*; name="ParkingSticker.java" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="ParkingSticker.java" class ParkingSticker { int ID; public ParkingSticker(int id) { ID = id; } } ------=_NextPart_000_0000_01C065F7.FC153670 Content-Type: java/*; name="tvisitor.java" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="tvisitor.java" import edu.neu.ccs.demeter.dj.*; import java.util.*; class tvisitor extends Visitor { // holds the path of traversed objects. private Hashtable path; // holds the number of time an object exists in the path. private Hashtable objCount; // return the hashtable that holds the path of the traversed objects. public Hashtable objPath() { return path; } public Object getLastObj(String className) { Integer iVal; if((iVal=(Integer)objCount.get(className)) == null) return null; else return path.get(new String(className+iVal.intValue())); } public int getNumObj(String className) { Integer iVal; if((iVal=(Integer)objCount.get(className)) == null) return 0; else return iVal.intValue(); } public void before(Object obj, Class cl) { // should this line be after inserting the object to the hashtable? invokeMethod("before", obj, cl); // to do: put the object in the path hashtable // update the objectCount Hashtable Integer iVal; int i; String className=cl.getName(); if((iVal=(Integer)objCount.get(className)) == null) i=1; else i=iVal.intValue()+1; objCount.put(className,new Integer(i)); String newObjType=className+i; path.put(newObjType,obj); } public void after(Object obj, Class cl) { // to do: take out the object from the path hashtable // update the objectCount Hashtable int i; String className=cl.getName(); if((i=((Integer)objCount.get(className)).intValue())==1) objCount.remove(className); else objCount.put(className,new Integer(i--)); path.remove(new String(className+i)); // should this line be before taking out the obkects from the hash? invokeMethod("after", obj, cl); } public String toString(){ //System.out.println("test: "+this.getClass().getName()); return super.toString() + " MyVisitor"; } } ------=_NextPart_000_0000_01C065F7.FC153670 Content-Type: java/*; name="University.java" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="University.java" import java.util.*; class University { private Employee maneger; private List faculty; public University(Employee mgr, List fcty) { maneger = mgr; faculty = fcty; } } ------=_NextPart_000_0000_01C065F7.FC153670--