ec9c5755bdb6c22f3d00e9f4916018cee2877ee0
1 package nl
.ru
.des
.bluetooth
;
3 import java
.util
.Arrays
;
4 import java
.util
.HashSet
;
8 import lejos
.robotics
.Color
;
9 import nl
.ru
.des
.LCDPrinter
;
11 public class ColorMemory
implements MessageHandler
{
12 public static final List
<Integer
> COLORSTOFIND
= Arrays
.asList(new Integer
[] {Color
.BLUE
, Color
.RED
, Color
.YELLOW
});
13 private Set
<Integer
> colors
;
15 public ColorMemory() {
16 colors
= new HashSet
<Integer
>();
20 public void handleMessage(String message
) {
21 colors
.add(Integer
.valueOf(message
));
22 LCDPrinter
.print(message
+ " received");
23 LCDPrinter
.print(colors
.toString());
26 public boolean finished() {
27 return colors
.containsAll(COLORSTOFIND
);
30 public void addColor(int current
) {
31 BTController
.sendMessage(Integer
.toString(current
));
33 LCDPrinter
.print(current
+ " found");
34 LCDPrinter
.print(colors
.toString());