PowersTopScribblesBroccoli

Broccoli

Next we talk about drawing broccoli rather than a bullseye or scribble. Amazingly, it is essentially the same idea. There is an interface BroccoliPart that contains two methods: move and contains. (Of course, if we were clever, we would just design a Draggable interface that contained all the methods that we'd expect to see in an object that could be dragged around.)

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.

Do chain reaction if there is time.


PowersTopScribblesBroccoli