In this assignment you will extend the problem solving framework introduced in class (see menu at left) by adding a graphical user interface (GUI) capability. Your relationship to the framework is therefore different than before: By adding a GUI to the framework's capabilities, all of the applicable domains — dummy problem, arithmetic problem, FWGC problem, and 8-puzzle problem — benefit without modification.

The only changes you will make are to the framework.ui package of the ProblemSolver project you used for the previous assignment.

For full credit, your job is to modify the framework so that a tabbed pane with the four problems is displayed, and for each problem:

For extra credit, you can choose either the FWGC or 8-Puzzle problem and present state displays using color graphics and animation.

Snapshots of examples of the four applications are shown in the menu to the left.

Note: Your job is not to copy the examples presented here exactly. In fact, you are encouraged to do a better job of choosing and styling your components.

This section shows snapshots of the GUIs for each of the four problem applications.

Also shown are snapshots showing illegal move and congratulations messages.

Here the farmer has attempted to cross with the wolf from the initial state.

Here the 8-puzzle has just been solved.

Recall the structure of the top-level problem-solving framework below:

You need to add a new concrete class, ProblemGUI, whose role is the same as ProblemConsole, as shown below.

ProblemGUI's only function is to present a GUI for a particular problem.

Gathering multiple GUIs in a tabbed pane will come at a later step.

First, add a new class, ProblemGUI.java, to the framework.ui package in your ProblemSolver project.

Like ProblemConsole, the ProblemGUI constructor should accept a Problem object and a width and height for the GUI's display area.

You can decide how to layout your GUI, whether with a BorderPane, HBox/VBox, GridPane, etc.

Whatever you decide, you should proceed by:

Suppose you layout using a VBox. Then one approach is to make ProblemGUI a subclass of VBox as shown below.

Now ProblemGUI can be tested in a way similar to how ProblemConsole was tested. For example, to test it on the FWGC problem, modify the FarmerProblemTest class as shown below.

Note that the scene is given a ProblemGUI object instead of a ProblemConsole object, and the display dimensions are slightly different.

Now add components to your GUI in incremental steps, starting with the welcome message, which can be constructed using the getName method in the Problem class.

Textual components can be represented using the Label class in the javafx.scene.control package.

Once you've created the component, add it to the layout container (in this case VBox) as shown here:

Now run (test) the FarmerProblemTest.java file as shown in "Setting Up." The result should look like:

Now add the problem's introduction, which also can be obtained from the Problem class:

The new result should look like:

For the next step, obtain the display shown below. Note:
Now obtain the display shown below. Note:
Finally, obtain the display below, which shows the congratulatory message and reset button.

The top-level control should be a TabPane, from package javafx.scene.control.

To create your final tabbed pane application, add the class ProblemTabPane to your framework.ui source package by right clicking the package and selecting New > Java Class...

To use ProblemTabPane.java, create a test class for it by right clicking it and selecting Tools > Create/Update Tests.
For extra credit, choose either the FWGC problem or 8-puzzle problem and replace the string-based state representation with color graphics and animation, as in the example below.

Here are suggested changes to the framework to accommodate graphics: The framework changes are shown in the class diagram below. Also shown is an implementation of the ProblemCanvas interface, namely a PuzzleCanvas class, to accomplish graphics display of the 8-puzzle, discussed next.

A class implementing ProblemCanvas, such as PuzzleCanvas, must depict the current state of the problem graphically. To accomplish this, Refer to the Java 8 Lab Exercise (see menu) for how to implement graphics and effect animations.
When your ProblemTabPaneTest.java file runs correctly: Note the general Submission Policy in the menu at left.

Your project will be inspected, tested, and run by the lab instructor. Grading criteria: