Pro Java 9 Games Development Leveraging the JavaFX APIs

(Michael S) #1
Chapter 22 ■ SCoring engine: Creating the SCore Ui LayoUt and SCoring the Content

private void createQAprocessing() {
a1Button.setOnAction(ActionEvent event) -> {


... // Empty ActionEvent Handling Lambda Expression Structure


});
}


Inside of your empty ActionEvent handling lambda expression, we’ll have conditional if() structures
for each of the Button objects that will look at both the picked Node object and the pickSn Random object
to ascertain which game board square (Q1S1 through Q4S5) and Random number generator value (pickS1
through pickS20) we’re dealing with. This will tell us which content we are looking at, and then our scoring
engine logic will score that choice.
Inside the a1Button.setOnAction() construct, add an if(picked == Q1S1) to start this coding process.
Notice that NetBeans error highlights the picked Node object, as it is currently local (private) to the
createSceneProcessing() method, as shown in Figure 22-24. We will have to make this picked Node object a
global (public) variable next.


Figure 22-23. Use the Alt+Enter keystroke and select and double-click the “Use lambda expression” option to
convert

Free download pdf