The Practice and Philosophy of Object-Oriented Programming in Java

New Practice Problems for Chapter 4

Flowers.  Write a JavaFX application called Flowers that displays 5 symmetrical flower shapes in a 500 x 500 scene as shown below. The start method does not directly create these shapes — the task is delegated to a helper method with parameters specifying the location of a flower and the horizontal and vertical radii of each petal. The method creates four ellipses differing only in their angle of rotation. These ellipses are the petals. They are combined into a single object of type Shape using the static Shape.union method, filled with a randomly generated color, and returned to the caller. The start method adds the returned shape to the root node. Provide a helper method to handle the task of creating a color with random RGB values.


Return to Companion Site home page