1. Snoopy will pick the first available item out of the box of decorations if you use pickThing(). Often the first items picked up are the Flashers! To get Snoopy to pick up the special decorations, you will need to use the "IPredicate" version of pickThing().
UNFORTUNATELY, the built-in IPredicates will not select the special decorations. You must build a new a class that uses IPedicate to find one.
FORTUNATELY,
this is very easy to do.
- Make a new class that implements (uses) IPredicate. (The new file is based on the above sample in Image A.) The new class will find out if something is your special decoration. (Hint: Make a new class with the above code changed to look for your special decoration.)
An example is included in the Robot documentation. The items highlighted indicated the items that should be changed. This give the example of a class that will tell if something is a Light. (Note: you need to add imports to this information.)
Image A: Example of a new IPredicated to pick up a Light.
 |
- When you try to pick up an item from the box of decorations, use the IPredicate version of pickThing. Since this special IPredicate is not built-in, we have to have Java use our version of the predicate. This is a bit complicated, so here is the basic code structure. (see the picture below).
Image B: This example uses the new predicate.
Use code similar to the example.

|
|