Added comments for the visitor example.

This commit is contained in:
Ilkka Seppala 2014-08-31 11:35:08 +03:00
parent 2e07a685b0
commit 9a0bb6b0fe
3 changed files with 17 additions and 0 deletions

View File

@ -1,5 +1,12 @@
package com.iluwatar; package com.iluwatar;
/**
*
* Visitor pattern defines mechanism to apply operations
* (UnitVisitor) on nodes (Unit) in hierarchy. New operations
* can be added without altering the node interface.
*
*/
public class App public class App
{ {
public static void main( String[] args ) public static void main( String[] args )

View File

@ -1,5 +1,10 @@
package com.iluwatar; package com.iluwatar;
/**
*
* Interface for the nodes in hierarchy.
*
*/
public abstract class Unit { public abstract class Unit {
private Unit[] children; private Unit[] children;

View File

@ -1,5 +1,10 @@
package com.iluwatar; package com.iluwatar;
/**
*
* Visitor interface.
*
*/
public interface UnitVisitor { public interface UnitVisitor {
void visitSoldier(Soldier soldier); void visitSoldier(Soldier soldier);