On this page:
Intro
1 Lab Skeleton
2 Bouncy Ball™
3 List  Of  Ball Extensions
4 Repetative Redundancies
5 Go Crazy!
6.12

Lab 9: Bouncy Ball™

Intro

You’ll work in this lab with your assigned partner. Help each other get up and running with IntelliJ and Java (Lab 4: Same Story, More Syntax).

The two of you will work as a team to solve problems. At any time, one of you will be the Head and the other will be the Hands. The Head does the thinking and the Hands does the typing. Hands type only what the Head tells them to, but you’re free to discuss any issues that pop up. You should switch off during the lab to make sure each of you get practice problem solving, dealing with syntax, and getting finger exercises on the keyboard.

1 Lab Skeleton

You must start this lab with this project skeleton. Unzip the file into your IdeaProjects directory and open it with IntelliJ to get started.

We’ll be using the JavaLib image and world library again in this lab; it’s all set up in the project skeleton. See the documentation for details about available classes/methods.

2 Bouncy Ball™

The TAs have taken your code from the past few labs and made a cheap clone of the Bouncy Bird game that we’ll call Bouncy Ball™. We want you to finish the game for us and clean up the code a bit.

Don’t worry if you haven’t finished the past few labs, you should start with the provided baseline program.

You can play the game right now, but it’s pretty boring. Spacebar bounces the ball up a bit; keep the green bouncy ball above the floor to continue playing. But there seem to be bugs in the new ListOfBall code we added.

3 ListOfBall Extensions

We needed to extend your ListOfBall interface to fit our needs. And by "we" we mean you.

Exercise 1: Complete the implementations of append inside the EmptyLoB and ConsLoB classes.

Exercise 2: Complete the implementations of exists inside the EmptyLoB and ConsLoB classes.

4 Repetative Redundancies

The TAs did a poor job combining your implementations to create the methods bounce, jump, and tick methods inside the Ball class. Each of those methods create a new ball with a modified vertical velocity and update the new ball’s position.

Exercise 3: Implement the method modifyVY as an abstraction of the bounce, jump, and tick methods. It consumes a unary function (Function<Integer, Integer>) that modifies the y-axis velocity of the ball. It should return a new ball with its positions adjusted by the current x-axis velocity and the new y-axis velocity.

Exercise 4: Simplify the implementations of the bounce, jump, and tick methods using your new modifyVY.

5 Go Crazy!

If you’re done, make any changes you want to the game. Make the obstacle balls change color every tick to stupify the player. Make the bouncy ball render as a bird. Do something else interesting and show it off to your TA!