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:
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:
Here are some more specific ideas about the three primary tasks:
You may want to add a new public message to the BowlingGame class. Before you do, send me your request first.
You don't need to show the shot curving toward the pins. Your bowling ball does not have to "hit" pins in any particular fashion, "bounce off" the pins, or even look like it is "knocking down" any particular pins.
You may keep it simple. Paint the pins in the right part of screen. When the user presses the button, a new bowling ball appears on the left and moves toward the pins. When it reaches the pin area, you can repaint the screen with the appropriate number of pins gone, and the ball, too.
Each time the user presses the button, the program can send a nextRoll() message to the BowlingRollStream. When the BowlingRollStream runs out of rolls from the file, it returns -1.
The "-f" is a switch which indicates that the next argument is a filename. The filename is the name of the file that contains the bowling rolls.
Your BowlingGame should use the filename to create a BowlingRollStream, use the BowlingRollStream to create a BowlingGameFrame, and then show the BowlingGameFrame.
If you'd like to do something more sophisticated, just run your idea by me first.
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.