-
Notifications
You must be signed in to change notification settings - Fork 0
/
CreateDraw.java
47 lines (43 loc) · 1.32 KB
/
CreateDraw.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import java.util.ArrayList;
public class CreateDraw
{
public static ArrayList<Integer> CreateDraw()
{
int ball = 0;
int temp = 0;
boolean newBall = false;
ArrayList<Integer> draw = new ArrayList<Integer>();
for(int x = 0; x < 6; x++)
{
do
{
ball = (int)Math.ceil((Math.random()*49));
if(!draw.contains(ball))
{
draw.add(ball);
newBall = true;
}
}while(newBall == false);
newBall = false;
if( x == 5)
{
for (int i = 1; i < draw.size(); i++) {
for(int j = i ; j > 0 ; j--){
if(draw.get(j) < draw.get(j-1)){
temp = draw.get(j);
draw.set(j,draw.get(j-1));
draw.set(j-1,temp);
}
}
}
}
}
// adds the bonus ball after the six main balls making sure that it doesn't match any of the main balls
do
{
ball=(int)Math.ceil(Math.random()*49);
}while(draw.contains(ball)==true);
draw.add(ball);
return draw;
}
}