-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLineUpGenerator.java
More file actions
44 lines (39 loc) · 1.25 KB
/
LineUpGenerator.java
File metadata and controls
44 lines (39 loc) · 1.25 KB
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
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package com.mycompany.project2;
import java.util.Random;
/**
*
* @author alihabibi
*/
public class LineUpGenerator {
public void generator(){
Random rand = new Random();
int[] lineup = new int[3]; // array of 3
int randomNumber = rand.nextInt(3); // random number 0 to 2
// If the random number is 0, generate a 4-3-3 formation
if (randomNumber == 0) {
lineup[0] = 4;
lineup[1] = 3;
lineup[2] = 3;
}
// If the random number is 1, generate a 5-3-2 formation
if (randomNumber == 1)
{
lineup[0] = 5;
lineup[1] = 3;
lineup[2] = 2;
}
else
//if the random number is 3, generate a 4-4-2 formation
{
lineup[0] = 4;
lineup[1] = 4;
lineup[2] = 2;
}
// Print the generated lineup
System.out.println("Lineup: " + lineup[0] + "-" + lineup[1] + "-" + lineup[2]);
}
}