Added comments for the visitor example.
This commit is contained in:
parent
2e07a685b0
commit
9a0bb6b0fe
@ -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 )
|
||||||
|
@ -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;
|
||||||
|
@ -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);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user