TODO9 - Use a switch statement to synchronize the ball state to the paddle state.
"public void paddleAndBallStateSynchronization()"
   
  1. Find the TODO9.java starter file; this empty class also serves as a solution you can experiment and play with.
  2. Next, read all of the comments at the top of the file in the file header.
  3. Set your runner in Main.java to use TODO9.java and comment out any other setRunner calls. (see the stepwise approach for more details)
  4. 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.
  5. Declare the function "public void paddleAndBallStateSynchronization(){}" and leave it empty and rerun the game - do you notice anything different?
  6. Inside your method, you must build one multi-way switch statement that mirrors the multi-way if/else statement you made in a previous todo.
  7. The switch staement uses cases, and the case FIRE asks: "if the paddle state is FIRE, then call some method to set the ball state to FIRE and break out of the switch"
  8. Extend the switch statement by adding another case statement: case ICE asks: "else if the paddle state is ICE, then call some method to set the ball state to ICE and break out of the switch"
  9. Extend the switch statement by adding another case statement: case NORMAL asks: "else if the paddle state is NORMAL, then call some method to set the ball state to NORMAL and break out of the switch"
  10. Inside your switch body, you'll need to call one or more API functions to set the state of the ball; the API function you'll need are are described in the comments and also listed here for reference:

  11. Method Signature Description
    PaddleAndBallStatesEnum paddleGetState() returns the current state of the paddle as one of the following: {FIRE, ICE, NORMAL}
    void ballSetState(PaddleAndBallStatesEnum state) call this function to set the state of the ball to one of the following: {FIRE, ICE, NORMAL}

    Type Values
    PaddleAndBallStates {NORMAL,FIRE,ICE}


A Ball in sync with the ICE Paddle above.

A Ball out of synch with the FIRE Paddle below.