TODO7 - Use a multi-way if/else statement to detect and handle ball and wall collisions.
"public void ballAndWallCollisionCheck()"
   
  1. Complete the lab section first for practice with Space Smasher before moving on to the assignment.
  2. Remember to experiment with your game by enabling and disabling the solution to observe the desired behaviour (see the Stepwise Approach below).
  3. Find the TODO7.java starter file; run the empty solution file and explore the behaviour that you will replicate with your code.
  4. Next, read all of the comments at the top of the file in the file header.
  5. Determine the single function you need to declare inside the empty class. It's described in the comments and also at the top of this webpage.
  6. Declare the function "public void ballAndWallCollisionCheck(){}" and leave it empty and rerun the game - do you notice any missing behaviour?
  7. Inside your method, you must build one if statement that asks: "if the wall that was hit was the TOP, then reflect off of the top wall and make a bounce sound."
  8. Augment your if statment by adding an else/if clause that asks: "else if the wall that was hit was the LEFT wall, then reflect off the left wall and make a bounce sound.
  9. Augment your if statment by adding an else/if clause that asks: "else if the wall that was hit was the RIGHT wall, then reflect off the right wall and make a bounce sound.
  10. Finish this if statment by adding an else/if clause that asks: "else if the wall that was hit was the BOTTOM wall, don't reflect but rather:
  11. Inside your if statement, you'll need to call one or more API functions to reflect the ball about a wall or lose a life, which are described in the comments and also listed here for reference:

  12. Method Signature Description
    WallsEnum getCollidedWall() returns either {LEFT, RIGHT, TOP, BOTTOM,NO_COLLISION} corresponding to the wall that the ball collided with.
    void ballReflectOffTopWall() call this function to reflect the ball about the x axis
    void ballReflectOffLeftWall() call this function to reflect the ball about the y axis
    void ballReflectOffRightWall() call this function to reflect the ball about the y axis
    void loseALife() call this function to reduce the lives in the lifeSet by one and lose the game if the set is 0.
    void ballPlayBounceSound() call this function to play a bouncy ball sound
    void ballSetToInvisible() call this function to make the ball go away (invisible)

    Type Values
    WallsEnum {LEFT, RIGHT, TOP, BOTTOM, NO_COLLISION}

  13. Once you've experimented with the methods above, consider playing with the extended set of methods below for even more complex and fun game behaviors

  14. Extended Method Signature Description
    void ballReflectOffTopWall(int whichBall) call this function to reflect the ball specified by whichBall about the x axis
    void ballReflectOffLeftWall(int whichBall) call this function to reflect the ball specified by whichBall about the y axis
    void ballReflectOffRightWall(int whichBall) call this function to reflect the ball specified by whichBall about the y axis
    void ballSetToInvisible(int whichBall) call this function to make the ball specified by whichBall go away (invisible)
    void ballReflectOffBottomWall() call this function to reflect the ball about the x axis - not needed in this TODO, but included for completeness.
    void ballReflectOffBottomWall(int whichBall) call this function to reflect the ball specified by whichBall about the x axis - not needed in this TODO, but included for completeness.