added visitor pattern sample
This commit is contained in:
16
visitor/src/main/java/com/iluwatar/App.java
Normal file
16
visitor/src/main/java/com/iluwatar/App.java
Normal file
@ -0,0 +1,16 @@
|
||||
package com.iluwatar;
|
||||
|
||||
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());
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user