Background:
This lab will provide you with another opportunity to work with classes
and objects as well as arrays. Once you're done, you will use
the Intro-CS Assignment Dropoff form to hand in your finished program.
What You'll Need
Nothing. You're writing this one from scratch.
Assignment
You are to write a set of classes that models a lottery machine similar to the lottery drawing seen on TV. A sample run will be shown in lecture on Thursday.
Specifications:
- The user must be prompted for the number of balls to be drawn from (max of 20) and the number of winning balls (max of 5) to be chosen from that pool.
- Numbers that are not in those ranges should not be accepted and your program should still behave reasonably.
- The balls must be stored in an array.
- The array must be shuffled before each ball is chosen (you can shuffle as many times as you want).
- Once a ball is "chosen" it is "removed" from the pool and cannot be chosen again. One way to do this is for the first shuffle to shuffle the entire array, with the winner being the ball that ends up in the [0]th element of the array. Then, the second shuffle shuffles all elements but the 0th one. Continue in this manner until the correct number of balls is chosen.
- The array of balls must be displayed before the first shuffle is
performed and after each subsequent shuffle.
- The winning balls must be displayed accompanied by a reasonable
message to the user.
- This virtual lottery machine uses a text interface. You don't need to construct anything graphical.
Think about your class design before coding your solution. Identify small classes that have well-defined behaviors (and the state needed to achieve that behavior). Avoid building an uber-class that does everything. If one of the behaviors does not seem to fit in with the others, it probably belongs in a separate class. You may wish to use a set of classes similar to the last lab.
Handing in your Solution
Your solution should be in the form of a .zip file. When we grade your solution
we will unzip the folder and execute the Java files.
Use the Intro Programming
dropoff form to submit your zip file.