Class pratice for March 21st, CS 106

Previously: We developed a simple ball following a trajectory in a single class. Last class, we started thinking about how to divide up that one class into multiple classes.

Today: I have now created three classes: Game, Ball, and Cannon. Two are (mostly) finished.

First, look at how the game class interacts with the cannon class. Make sure you understand how the constructor and setAngle methods work.

Second, you'll see that there are two calls to the Ball class, which is not finished. Your job is to take the outline of Ball.java and fill in the two methods (the constructor and animate()). You will likely want to use code we developed earlier, either from Monday's class, or by using the code from before spring break (10AM and 11AM).

Third, modify Game and Cannon so that the keyboard will change the angle of the cannon (which affects the initial speed of the ball), and let the user press a button to fire the ball. You may want to use something like:

if (MyroListener.isKeyPressed())
{
    char choice = MyroLister.whichKey();
    if (choice=='a')
    {
        ....
    }
    else if (choice == 'b') 
   ....
}