Homework Assignment 7

A Graphical Bowling Game

Computer Science II
Object-Oriented Programming

Due: Thursday, March 31, at 8:00 AM


First came the BowlingGame, which computes the score of a game and print its scoresheet.

Then came the BallWorld, in which a ball moves about a window on the screen.

Now comes the natural next step in the fantasy that is Computer Science II: BowlingGameWorld.

This assignment gives you an opportunity to create your first graphical program. You may use the various BallWorld, MultiBallWorld, and even CannonGame programs as a starting point, but this program is all your own. Feel free to meet the minimum requirements of the assignment and then add your own personal flourish to your program!

*** Programming Advice

As always, you should write your program in the style we have used all semester long:

Take small steps, and your tests will give you feedback as soon as possible. Use the GenerateTest program to create your test class.

*** Code Base

Use the following code as your starting point:

New Java


A Java Label is a component that can be added to a Frame, like a Button. Labels do not give the use a way to give input; they are for displaying text only. You can change a Label's text by sending it a setText() message. Other useful messages include getText() and setAlignment().

You create a Label and add it to a Frame just as yu would a Button, but you don't add a listener to it.

Note: Java Label do not recognize embedded new-line characters, so whatever you display in one will appear on a single line.


A BowlingGameWorld has three parts:

  1. At the top of the window is text that shows at least the current frame number and the current score of the game.
  2. At the bottom of the window is a button that allows the user roll a bowling ball.
  3. In the middle of the window is where a bowling ball rolls and "knocks down" some pins.

Here are some more specific ideas about the three primary tasks:

At first, focus your attention on creating a good set of objects to implement the program. Once you have a decent set of objects orking together, if you have the time and energy, you may go beyond the simple graphics described above to do something more.


By the due date and time, submit these files:

Be sure that your submission follows all homework submission requirements.

Eugene Wallingford ..... wallingf@cs.uni.edu .... March 14, 2005