package com.javadude.tms;

import com.javadude.template2withstrategy.NodeStrategy;
import com.javadude.template2withstrategy.Walker2;

public class App3 {
	private static class NodePrinter implements NodeStrategy {
		@Override
		public void dealWithMe(BinaryTreeNode node) {
			System.out.println(node.getData());
		}
	}
	
	public static void main(String[] args) {
		BinaryTreeNode root = new BinaryTreeNode(42);
		root.insert(84);
		root.insert(57);
		root.insert(10);
		root.insert(31);
		root.insert(93);
		root.insert(4);

		Walker2 walker2 = new Walker2();

		NodePrinter nodePrinter = new NodePrinter();
		
		System.out.println("Pre Order");
		System.out.println("========");
		walker2.setPreOrder(nodePrinter);
		walker2.walk(root);
		System.out.println();

		System.out.println("In Order");
		System.out.println("========");
		walker2.setPreOrder(null);
		walker2.setInOrder(nodePrinter);
		walker2.walk(root);
		System.out.println();
		
		System.out.println("Post Order");
		System.out.println("========");
		walker2.setInOrder(null);
		walker2.setPostOrder(nodePrinter);
		walker2.walk(root);
	}
}

@@ -68,271 +68,39 @@
 egy.
-NodeStrategy;%0D%0Aimport com.javadude.template2withstrategy.Walker2;%0D%0A%0D%0Apublic class App3 %7B%0D%0A%09private static class NodePrinter implements NodeStrategy %7B%0D%0A%09%09@Override%0D%0A%09%09public void dealWithMe(BinaryTreeNode node) %7B%0D%0A%09%09%09System.out.println(node.getData());%0D%0A%09%09%7D%0D%0A%09%7D%0D%0A%09
+Walker2;%0D%0A%0D%0Apublic class App3 %7B
 %0D%0A%09p
@@ -352,60 +352,8 @@
 %0D%0A%0D%0A
-%09%09NodePrinter nodePrinter = new NodePrinter();%0D%0A%09%09%0D%0A
 %09%09Sy
@@ -437,35 +437,71 @@
 setPreOrder(
+(
 node
-Printer
+) -%3E %7BSystem.out.println(node.getData());%7D
 );%0D%0A%09%09walker
@@ -659,35 +659,71 @@
 .setInOrder(
+(
 node
-Printer
+) -%3E %7BSystem.out.println(node.getData());%7D
 );%0D%0A%09%09walker
@@ -894,19 +894,55 @@
 der(
+(
 node
-Printer
+) -%3E %7BSystem.out.println(node.getData());%7D
 );%0D%0A

Use lambda