#107 Improve JavaDoc for Visitor example

This commit is contained in:
Ilkka Seppala
2015-08-21 23:27:25 +03:00
parent 35e1afd7dc
commit d220a0753a
2 changed files with 50 additions and 41 deletions

View File

@ -1,27 +1,31 @@
package com.iluwatar.visitor;
/**
*
* Visitor pattern defines mechanism to apply operations on nodes
* in hierarchy. New operations can be added without altering the node
* interface.
*
* In this example there is a unit hierarchy beginning from Commander.
* This hierarchy is traversed by visitors. SoldierVisitor applies
* its operation on Soldiers, SergeantVisitor on Sergeants and so
* on.
*
*/
public class App {
public static void main(String[] args) {
Commander commander = new Commander(new Sergeant(new Soldier(),
new Soldier(), new Soldier()), new Sergeant(new Soldier(),
new Soldier(), new Soldier()));
commander.accept(new SoldierVisitor());
commander.accept(new SergeantVisitor());
commander.accept(new CommanderVisitor());
}
}
package com.iluwatar.visitor;
/**
*
* Visitor pattern defines mechanism to apply operations on nodes
* in hierarchy. New operations can be added without altering the node
* interface.
* <p>
* In this example there is a unit hierarchy beginning from {@link Commander}.
* This hierarchy is traversed by visitors. {@link SoldierVisitor} applies
* its operation on {@link Soldier}s, {@link SergeantVisitor} on {@link Sergeant}s and so
* on.
*
*/
public class App {
/**
* Program entry point
* @param args command line args
*/
public static void main(String[] args) {
Commander commander = new Commander(new Sergeant(new Soldier(),
new Soldier(), new Soldier()), new Sergeant(new Soldier(),
new Soldier(), new Soldier()));
commander.accept(new SoldierVisitor());
commander.accept(new SergeantVisitor());
commander.accept(new CommanderVisitor());
}
}