I'm a visitor, i would visit the ones i knew.

I'm learning Design Pattern, Here is what i think about the visitor Pattern. if something wrong, please inform me. thanks

//I'm a visitor, i could visit the ones i knew.//if i want to visit a new one, i must know him, and he must accept me first.//the following is Me -- a visitor, and i know He and She, they both accept me.interface Visitor {
publicvoid visit(He h); // i know himpublicvoid visit(She s); // i know her
}
class He {
publicvoid accept(Visitor me) { // he accepts me
me.visit(this); // so i could visit him
}
}
class She {
publicvoid accept(Visitor me) { // she accepts me 2
me.visit(this); // so i could visit her
}
}
//and now if i want to visit It, i must know It, that is:interface Visitor {
publicvoid visit(He h); // i know himpublicvoid visit(She s); // i know herpublicvoid visit(It i); // i must know it first
}
class It {
publicvoid accept(Visitor me) { // and it must accept me 2.
me.visit(this); // so i could visit it.
}
}
// at this time, i could visit them separately//if i want to visit them one by one, i must know all of them, and each of them must accept me. that is:interface Acceptable {
publicvoid accept(Visitor me);
}
// and each of them is acceptable, so :class He implements Acceptalbe {
publicvoid accept(Visitor me) { // he accepts me
me.visit(this); // so i could visit him
}
publicvoid running() { }
}
class She implements Acceptalbe {
publicvoid accept(Visitor me) { // she accepts me 2
me.visit(this); // so i could visit her
}
publicvoid crying() { }
}
class It implements Acceptalbe {
publicvoid accept(Visitor me) { // and it also accept me.
me.visit(this); // so i could visit it.
}
publicvoid sleeping() { }
}
//now, i was visiting all the one i knows here:class Visiting {
publicstaticvoid main(String []args) {
Visitor me=new Visitor() { // this is the real Mepublicvoid visit(He h) { // and i know all of them
h.runing();
}
publicvoid visit(She s) {
s.crying();
}
publicvoid visit(It i) {
i.sleeping();
}
};
Collection me=new LinkedList(); // now i'm ready to visit them
me.add(new He());
me.add(new She());
me.add(new It());
Iterator iter = me.iterator();
while ( iter.hasNext() ) { // so i will visit them one by one.
Acceptable x=(Acceptable)iter.next();
x.accept(me); // and they all accept me, so i could visit them successful them.
}
}
}
<p>