TODO8 - Use a switch 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 TODO8.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 a switch statement and a case inside of the switch that asks: "if it was the case that the wall hit was the TOP, then reflect off of the top wall and make a bounce sound."
  8. Augment your switch statment by adding another case that asks: "if it was the case that the wall hit was the LEFT wall, then reflect off the left wall and make a bounce sound.
  9. Augment your switch statment by adding an additional case that asks: "if it was the case that the wall hit was the RIGHT wall, then reflect off the right wall and make a bounce sound.
  10. Finish this switch by adding the final case that asks: "if it was the case that the wall hit was the BOTTOM wall, don't reflect but rather:
  11. Inside your case statements, 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 reduce the lives in the lifeSet by one and lose the game if the set is 0.

    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 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.