for our coursework we had to make a lottery random number ticket generator
The Numbers class should provide the following functionality:
Generates 6 random numbers in a range 1 to 49.
Write YOUR OWN custom method incorporating an algorithm to sort the numbers in ascending order.
Store the 6 numbers in a fixed-sized collection (array).
Format and display the numbers (number output in the range 1 to 9 should be preceded by a blank space).
The Ticket class should provide the following functionality:
Construct a Lottery Ticket that allows the customer to have as many randomly generated Lucky Dips as they require on the same ticket.
Store the ‘Lucky Dip’ number sets in a flexible-sized collection (array list).
Display the ticket and ‘Lucky Dip’ numbers to the screen in the correct format.
i have started with the numbers class and my question is that im i on the right path also can anyone guide me because somewhere i need a loop
//access to the java.utill.random libary.
import java.util.Random;
/**
* Lucky dip lottery ticket system.
* @author Daniel Prempeh
* @version 1.1 2013
*/
public class Numbers
{
private int[] Lotto;
private final int MAX=6;
public Numbers()
{
Lotto = new int[MAX];
}
public void generateNums(int qty)
{
//assign random value to 6 lines of intergers.
Lotto[0] = 1 + (int) (Math.random() * 49);
Lotto[1] = 1 + (int) (Math.random() * 49);
Lotto[2] = 1 + (int) (Math.random() * 49);
Lotto[3] = 1 + (int) (Math.random() * 49);
Lotto[4] = 1 + (int) (Math.random() * 49);
Lotto[5] = 1 + (int) (Math.random() * 49);
//Print out the line of numbers.
System.out.println(Lotto[0] + ", " + Lotto[1] + ", " + Lotto[2] + ", " + Lotto[3] + ", " + Lotto[4] + ", " + Lotto[5]);
}
}