1 package nl
.ru
.des
.bluetooth
;
3 import java
.util
.Arrays
;
4 import java
.util
.HashSet
;
8 import lejos
.hardware
.Sound
;
9 import lejos
.robotics
.Color
;
10 import nl
.ru
.des
.LCDPrinter
;
12 public class ColorMemory
implements MessageHandler
{
13 public static final List
<Integer
> COLORSTOFIND
= Arrays
.asList(new Integer
[] {Color
.BLUE
, Color
.RED
, Color
.YELLOW
});
14 private Set
<Integer
> colors
;
16 public ColorMemory() {
17 colors
= new HashSet
<Integer
>();
21 public void handleMessage(String message
) {
22 int color
= Integer
.valueOf(message
);
23 if(!colors
.contains(color
)){
24 colors
.add(Integer
.valueOf(message
));
26 LCDPrinter
.print(colors
.toString());
30 public boolean finished() {
31 return colors
.containsAll(COLORSTOFIND
);
34 public void addColor(int current
) {
35 if(!colors
.contains(current
)){
38 LCDPrinter
.print(colors
.toString());
39 BTController
.sendMessage(Integer
.toString(current
));