/** Create a solver instance and configures it with initial and goal state. */ private void constructPuzzleSolver() { pSolver = null; // this is the call to the actual implementation of PuzzleSolver if ("DFS".equals(solver)) pSolver = new DFSSolver(); if ("BFS".equals(solver)) pSolver = new BFSSolver(); if ("ASTAR".equals(solver)) pSolver = new AStarSolver(); if (null == pSolver) // default case, make sure we have a solver pSolver = new BFSSolver(); pSolver.configure(initalPuzzleGraphics.getPuzzle(), finalPuzzleGraphics.getPuzzle()); }