Skip to content

Commit 6f55b91

Browse files
committed
Implemented selectors.
1 parent bb28276 commit 6f55b91

File tree

3 files changed

+51
-0
lines changed

3 files changed

+51
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.iluwatar;
2+
3+
import java.util.function.Predicate;
4+
5+
public class ColorSelector implements Predicate<Creature> {
6+
7+
private final Color c;
8+
9+
public ColorSelector(Color c) {
10+
this.c = c;
11+
}
12+
13+
@Override
14+
public boolean test(Creature t) {
15+
return t.getColor().equals(c);
16+
}
17+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.iluwatar;
2+
3+
import java.util.function.Predicate;
4+
5+
public class MovementSelector implements Predicate<Creature> {
6+
7+
private final Movement m;
8+
9+
public MovementSelector(Movement m) {
10+
this.m = m;
11+
}
12+
13+
@Override
14+
public boolean test(Creature t) {
15+
return t.getMovement().equals(m);
16+
}
17+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.iluwatar;
2+
3+
import java.util.function.Predicate;
4+
5+
public class SizeSelector implements Predicate<Creature> {
6+
7+
private final Size s;
8+
9+
public SizeSelector(Size s) {
10+
this.s = s;
11+
}
12+
13+
@Override
14+
public boolean test(Creature t) {
15+
return t.getSize().equals(s);
16+
}
17+
}

0 commit comments

Comments
 (0)