ITEC 120 LAB 9 Back to Lab index page

Pick 3 lotto number

Write a class which can generate Pick3 lotto numbers, and a driver which will test this class.

A Pick3 lotto number is 3 numbers, each number is one digit ( 0 through 9 ). Example: 4 0 9

Write a class to represent a Pick3 number. Here's a UML diagram for the class:

Pick3

- num1 : int
- num2 : int
- num3 : int

+ Pick3()
+ quickPick() : void
+ toString() : String

A Pick3 object stores 3 pieces of data: the three numbers, all ints. The constructor randomly generates those 3 numbers. The method quickPick also randomly generates the 3 numbers -- it will change them to a new set of random numbers. The toString method formats the 3 numbers as a String.

Write a driver which instantiates a Pick3 object, and prints it out. Then, call the quickPick method a couple of times, printing out the object after each call to quickPick().

Show your code and your working program to your instructor or peer instructor to be checked off.