Download a copy of the jar file (/~cs1/pub/lab06/lab6.jar) that contains the files you need to complete this lab and unpack it in the subdirectory you created for your CS1 lab work.
In order to get a feel for how this program fits together, you will write it in several stages. At the end you should have a working Lotto game. Before we get started though, take a couple of minutes to play the working version of the game. From a Unix prompt execute the following command:
If everything worked correctly you should see the lotto screen displayed on your terminal. Before you can play the game you must select 6 lucky numbers. You select a number by clicking on the numbered button that contains the number you want. When you select a number the button should turn blue. You can unselect a number by clicking on it a second time. Once you have your numbers selected, cross your fingers, and click the draw button. The computer will select 6 numbers at random and display them on the board. If you and the computer selected the same number, the corresponding numbered button will turn yellow. Any numbers the computer selected, that you did not, will turn green. You can click the draw button as many times as you wish. Feel free to change your lucky numbers if they turn out not to be all that lucky. The game maintains statistics that let you see how well you are doing.
There are two other buttons on the interface that were not described above. Take a few minutes to figure out what they do. The names of the buttons should give you a good idea of what the buttons do.
Keep in mind that this version of the program is a sort of combination of the versions of the games you will write. It is not exactly the same as any single one of them.
Your first task is to familiarize yourself with the javadoc for the Lotto Program
. The file
Lotto.java simply starts up the program.
BallBox.java is used to generate the random numbers the computer will draw for the user. You will not need to change this code, but you should understand how to use it.
The interesting classes in the Lotto program are the ones contained in the files:
LottoLogic.java. The LottoGUI class creates, and manages the GUI for the program. Take a few minutes to look at the documentation for this class. You will be modifying the LottoLogic class which implements the logic of the game in activities 2 - 5. For now familiarize yourself with the LottoLogic class and find the three methods that you must complete (
You received a
questions.txt file when you downloaded the files for this lab. Use emacs to edit the file and replace the phrases YOUR_ANSWER_HERE with the answers to each question.
When you are done, save your file and submit it using the following command:
Copyright RIT 2003