The Practice and Philosophy of Object-Oriented Programming in Java

New Practice Problems for Chapter 9

Triangulation.  Write a JavaFX application that displays a square partitioned into four triangles and provides checkboxes to control the visibility of the triangles. The root node is a BorderPane. Add a 200 × 200 Pane to the center to hold the triangles (Polygon objects). You can set the size of the pane with its setMinSize method. The checkboxes are contained in the top, bottom, left, and right regions of the border pane. The event handler for a checkbox sets the visibility of the associated triangle by calling its setVisible method.

   
   

Box of Lights.  Combine solutions to Practice Problems 9.9.4a (Lights Out) and 9.9.4c (Cross Flips) in a single JavaFX front end with a toggle button for selecting the game to play.


Harakka.  This is a continuation of Harakka (see new practice problems for Chapter 8). Write a JavaFX front end for the game using buttons as the game tiles. When the game is over, display an alert box with the number of moves and terminate the application as shown below.

// create and configure alert box
stage.close();
alert.showAndWait();


Harakka 2.  Enhance a solution to the previous problem with additional options and effects. Possible options include the following.

If you feel ambitious, try to implement one or more of the following effects.


Return to Companion Site home page