Final Project:  The Moving Blinking Bugs

Your task is to write a moving blinking bug program.  

Your program should have an array of 7 to 10 bugs.  Each bug should have two eyes.  When you click on the eye of a bug, and the eye was open, it should close.  If you click on the eye of a bug and it was closed, it should open.  If you click on a bug outside the eyes, the next click should tell where the bug moves to.

Your program should have three classes:

The Eye Class

Variables
  • x, y:  Where the eye is
  • open:  a 1 if the eye is opened, a zero otherwise
Methods
  • paint:  Draw the eye either open or closed based on the variable open
  • doclick:  If the click is within the eye, change the open variable and return true else return false

The Bug Class

Variables:
  • x, y -- location of the bug
  • lefteye, righteye -- The eyes

Methods
  • paint:  Draws the bug at x, y with the eyes correctly drawn based on lefteye, righteye
  • didclick:  If the click is on an eye, changes that eye.  Return true if the click was on an eye.
  • contains: Returns true/false based on if the click in within the bug

The Main Class

Variables
  • An array of bugs
  • x, y:  Where the mouse was clicked.
  • selected:  which bug was selected to move, or -1 if none were selected
Methods
  • paint:  Draw each bug
  • mouseclick:  
    if selected > -1
        move bug[selected] to that x,y
        selected = -1
    else
        find the bug that was clicked using the contains method
        call doclick on that bug
        if didclick says false
              set selected to be this bug