Never mind.
Easiest solution would be to allocate another array of 8 random non-repeating numbers for your lottery.
This should work too, though I'm not 100% sure about the implementation of your code.
Easiest solution would be to allocate another array of 8 random non-repeating numbers for your lottery.
Code:
int countV=0;
while (countV<8)
{
int num=(int)(1+Math.random()*(30));
for (int i=0;i<=array1.length-1 ;i++ )
{
if (num == array1[i].getLotID() && array1[i].getFlag())
countV--;
else if (num == array1[i].getLotID())
{
//System.out.println("TEST");
//System.out.println(array1[i].toStringP());
array1[i].setVehicleProject(array[countV]);
array1[i].setFlag(true);
}
}
countV++;
}
for (int i=0;i<=array1.length-1 ;i++ )
{
if (array1[i].getFlag())
{
System.out.println(array1[i].getFirstName()+" is a Winner");
}
else
{
System.out.println(array1[i].getFirstName()+" is a Loser");
}
}This should work too, though I'm not 100% sure about the implementation of your code.

