-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChocolateBox.java
More file actions
35 lines (26 loc) · 820 Bytes
/
ChocolateBox.java
File metadata and controls
35 lines (26 loc) · 820 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
33
34
35
import java.util.Random;
public class ChocolateBox {
enum Chocolate {
CARAMEL, MARSHMALLOW, DARK, NOUGAT, MILK
}
public static Chocolate[] createBox() {
Random rand = new Random();
Chocolate[] box = new Chocolate[6];
for(int i=0; i<box.length; i++) {
int randomChoc = rand.nextInt(5);
box[i] = Chocolate.values()[randomChoc];
}
return box;
}
public static void printBox(Chocolate[] a) {
System.out.println("Your assortment of chocolates includes: ");
for(int i=0; i<a.length; i++) {
System.out.println(a[i].name());
}
System.out.println();
}
public static void main(String[] args) {
printBox(createBox());
printBox(createBox());
}
}