error message cannot find constructor lottery(int[])
import java.util.Random;
public class Lottery
{
private final int NUM_DIGITS = 5;
private int[] lotteryNumbers = new int[NUM_DIGITS];
private int[] userNumbers;
private int matches;
public int[] getLottery(int[] l)
{
// Create an array the length of l.
lotteryNumbers = new int[5];
// Random object.
Random rand = new Random();
//Defines elements of l. Copy elements from l to lotteryNumbers.
for (int i = 0; i < 5; i++)
{
lotteryNumbers[i] = rand.nextInt(9);
lotteryNumbers[i] = l[i];
}
return lotteryNumbers;
}
public int[] getUser(int[] u)
{
// Create an array the length of l.
userNumbers = new int[5];
//Defines elements of l. Copy elements from l to lotteryNumbers.
for (int i = 0; i < 5; i++)
userNumbers[i] = u[i];
return userNumbers;
}
public int getMatches()
{
matches = 0;
for (int i = 0; i < 5; i++)
{
if (userNumbers[i] == lotteryNumbers[i])
matches = matches + 1;
else
matches = matches + 0;
}
return matches;
}
}
.
import java.util.Scanner;
public class Lotto
{
public static void main(String[] args)
{
final int NUMBERS = 5;
int[] winNumbers = new int[NUMBERS];
int[] userNumbers = new int[NUMBERS];
int matches;
Scanner keyboard = new Scanner(System.in);
Lottery lot = new Lottery(userNumbers);
for (int i = 0; i < NUMBERS; i++)
{
System.out.print("Number " + (i + 1) + ": ");
userNumbers[i] = keyboard.nextInt();
lot.getUser(userNumbers);
}
for (int h = 0; h < NUMBERS; h++)
{
matches = lot.getMatches();
}
System.out.println("The winning numbers are:");
for (int j = 0; j < NUMBERS; j++)
{
lot.getLottery(winNumbers);
System.out.print(winNumbers[j] + "\t");
}
System.out.println("\n");
if (matches == 5)
System.out.println("You are a grand prize winner!");
else
System.out.println("You matched " + matches + " out of 5 numbers. Better luck next time.");
}
}