Skip to content

Instantly share code, notes, and snippets.

@jraczak
Created July 29, 2015 22:01
Show Gist options
  • Save jraczak/446d8053d0b2a2fdfed0 to your computer and use it in GitHub Desktop.
Save jraczak/446d8053d0b2a2fdfed0 to your computer and use it in GitHub Desktop.
Garden of Java
public class Flower
{
private int x;
private int y;
public Flower(int theX, int theY)
{
this.x = theX;
this.y = theY;
}
/**
* This function draws the flower.
*/
public void draw()
{
Ellipse topPetal = new Ellipse(this.x + 20, this.y, 20, 20);
topPetal.draw();
topPetal.setColor(Color.PINK);
topPetal.fill();
Ellipse rightPetal = new Ellipse(this.x + 40, this.y + 20, 20, 20);
rightPetal.draw();
rightPetal.setColor(Color.PINK);
rightPetal.fill();
Ellipse leftPetal = new Ellipse(this.x, this.y + 20, 20, 20);
leftPetal.draw();
leftPetal.setColor(Color.PINK);
leftPetal.fill();
Ellipse bottomPetal = new Ellipse(this.x + 20, this.y + 40, 20, 20);
bottomPetal.draw();
bottomPetal.setColor(Color.PINK);
bottomPetal.fill();
Ellipse center = new Ellipse(this.x + 20, this.y + 20, 20, 20);
center.draw();
center.setColor(Color.YELLOW);
center.fill();
Line stem = new Line(this.x + 30, this.y + 60, this.x + 30, this.y + 120);
stem.draw();
stem.setColor(Color.GREEN);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment