Class Butterfly
- java.lang.Object
-
- Butterfly
-
public class Butterfly extends java.lang.Object
A Butterfly object represents a butterfly that is drawn in a window. The butterfly is shown on the window as two ovals, with coloured spots. The class needs a constructor that takes a position (x and y) to start the butterfly, and will draw the new butterfly on the canvas. The move method takes a change in x and a change in y to move the position of the butterfly. The class will also need methods to erase and draw the butterfly. The move method pick methods should first call the erase method, then change the relevant field values, and then call the draw method.
-
-
Constructor Summary
Constructors Constructor Description Butterfly(double x, double y)
Constructor: Requires the initial position
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
land()
Make the butterfly drop to the bottom of the window and (mostly) close its wings.void
move(double speed)
Move will change the position of the butterfly while flapping its wings a little bit.
-
-
-
Method Detail
-
move
public void move(double speed)
Move will change the position of the butterfly while flapping its wings a little bit. The argument specifies how big a step to take. It will first erase the butterfly, then change its x and y, and then draw it again.
-
land
public void land()
Make the butterfly drop to the bottom of the window and (mostly) close its wings.
-
-