package daisy; import wheels.users.*; public class DaisyFor { protected ConversationBubble bubble; protected byte numPetalsPlucked; protected Ellipse center; protected Rectangle stem = new Rectangle(java.awt.Color.green); public DaisyFor(int x, int y, ConversationBubble bubble) { this.bubble = bubble; int radius = 20; x += radius; y += radius; stem.setSize(10, 100); stem.setLocation(x - 15, y + 40); int radius1 = 30; numPetalsPlucked = 0; int count = 30; int delta = (int)(360 / count); for (int i = 0, angle = 0; i < count; i++, angle += delta) { new PetalFor(x + (int)(radius1 * Math.cos (angle * Math.PI / 180)) , y + (int)(radius1 * Math.sin (angle * Math.PI / 180)), this); } center = new Ellipse(java.awt.Color.yellow); center.setLocation(x - radius, y - radius); center.setSize(2 * radius, 2 * radius); } public void petalPlucked() {//final version with ternery operator numPetalsPlucked++; bubble.setText("Loves me" + (numPetalsPlucked < 9 ? " not." : ".")); } public void petalPluckedOriginalVersion () { numPetalsPlucked++; if (numPetalsPlucked < 9) { bubble.setText("Loves me not."); } else { bubble.setText("Loves me."); } } public void petalPluckedTextVersion() { numPetalsPlucked++; String text = null; if (numPetalsPlucked < 9) { text = "Loves me not."; } else { text = "Loves me."; } bubble.setText(text); } }