-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLottery.java
More file actions
32 lines (25 loc) · 866 Bytes
/
Lottery.java
File metadata and controls
32 lines (25 loc) · 866 Bytes
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
import java.util.Random;
/** Performs the lottery to determine the order in which ticket requests will be fulfilled
*
* Lottery Class
* @author Danny Guan
* @version 1
*/
public class Lottery{
/** Randomized the array which the ticket requests are stored in
*
* @param requests - array with all of the ticket requests
* @return the array with the ticket request order randomized
*/
public CustomerInformation[] RandomizeOrder(CustomerInformation[] requests) {
Random random = new Random();
// Sorts array of requests
for (int i = requests.length - 1; i > 0; i--) {
int index = random.nextInt(i + 1);
CustomerInformation change = requests[i];
requests[i] = requests[index];
requests[index] = change;
}
return requests;
}
}