Broccoli |
The simplest broccoli part is a flower, which is generated by class Flower, which implements BroccoliPart. More complicated broccoli is generated by the class Broccoli, which consists of a stem and three broccoli parts that stick out from the end of the stem at different angles. Notice that the constructors for all of the broccoli parts take an angle (given in radians) that determines at which angle the main stem is tipping. See BroccoliDrag for a demo of the program and the code.
To make this even more interesting looking, we have written a slight variant of this program where we make each broccoli part into an active object so that when it is constructed there is a short delay and then the new pieces are drawn. See LivingBroccoli for a demo of the program and the code.
Broccoli |