new data member -- a flower create the flower when the balloon is created position the flower where the balloon is create the flower when the balloon is created position the flower where the balloon is show the flower with the balloon move the flower to where balloon us spin the flower in the wind
package cs1.ParkApp; import cs1.app.*; public class Balloon { // data members: the "features/characteristics" of Balloon // typically private private String color; private double size; private double curX; private double curY; private Flower flower; // NEW: balloon has a flower that will be drawn on top // constructor(s): same name as class, no return type public Balloon( String initColor, double initSize, double initX, double initY ) { color = initColor; // set each "feature" to what user specified size = initSize; curX = initX; curY = initY; flower = new Flower( color ); // NEW: make the balloon's flower flower.setX( curX ); // NEW: position the flower at the balloon flower.setY( curY ); // NEW: position the flower at the balloon } public Balloon( String initColor, double initSize ) { color = initColor; size = initSize; curX = 0; curY = 0; flower = new Flower( color ); // NEW: make the balloon's flower flower.setX( curX ); // NEW: position the flower at the balloon flower.setY( curY ); // NEW: position the flower at the balloon } // methods: the "actions/behaviors" of Balloon // typically public public String getColor( ) { return color; } public double getSize( ) { return size; } public void draw( ) { canvas.drawCircle( curX, curY, size, color ); flower.draw(); // NEW: show the flower } public void drift( double dx, double dy ) { curX = curX + dx; curY = curY + dy; flower.setX( curX ); // NEW: move flower to balloon position flower.setY( curY ); flower.spin( ); // spin flower in the wind } }