Skip to content

Commit 58702d8

Browse files
committed
small fixes to lottery example
1 parent a3f7943 commit 58702d8

1 file changed

Lines changed: 18 additions & 15 deletions

File tree

java/examples/Topics/Advanced Data/IntListLottery/IntListLottery.pde

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,30 +24,33 @@ void draw() {
2424
background(51);
2525

2626
lottery.shuffle();
27-
28-
showList(lottery,16,48);
29-
showList(results,16,100);
30-
showList(ticket,16,140);
31-
27+
28+
showList(lottery, 16, 48);
29+
showList(results, 16, 100);
30+
showList(ticket, 16, 140);
31+
3232
for (int i = 0; i < results.size(); i++) {
3333
if (results.get(i) == ticket.get(i)) {
34-
fill(0,255,0,100);
35-
} else {
36-
fill(255,0,0,100);
34+
fill(0, 255, 0, 100);
35+
}
36+
else {
37+
fill(255, 0, 0, 100);
3738
}
3839
ellipse(16+i*32, 140, 24, 24);
3940
}
4041

4142
if (frameCount % 30 == 0) {
43+
// Pick a new lottery number!
4244
if (results.size() < 5) {
43-
int val = lottery.get(0);
44-
lottery.remove(0);
45-
results.append(val);
45+
int val = lottery.get(0);
46+
lottery.remove(0);
47+
results.append(val);
4648
} else {
47-
for (int i = 0; i < results.size(); i++) {
48-
lottery.append(results.get(i));
49-
}
50-
results.clear();
49+
// Ok we picked five numbers, let's reset
50+
for (int i = 0; i < results.size(); i++) {
51+
lottery.append(results.get(i));
52+
}
53+
results.clear();
5154
}
5255
}
5356
}

0 commit comments

Comments
 (0)