parent
707e16dbe1
commit
44c0e96211
@ -0,0 +1,30 @@
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class ColorFilter {
|
||||
private String targetColor;
|
||||
|
||||
public ColorFilter(String targetColor) {
|
||||
this.targetColor = targetColor;
|
||||
}
|
||||
|
||||
public List<Shape> filterByColor(List<Shape> shapes) {
|
||||
List<Shape> filteredShapes = new ArrayList<>();
|
||||
|
||||
for (Shape shape : shapes) {
|
||||
if (shape.getColor().equalsIgnoreCase(targetColor)) {
|
||||
filteredShapes.add(shape);
|
||||
}
|
||||
}
|
||||
|
||||
return filteredShapes;
|
||||
}
|
||||
|
||||
public String getTargetColor() {
|
||||
return targetColor;
|
||||
}
|
||||
|
||||
public void setTargetColor(String targetColor) {
|
||||
this.targetColor = targetColor;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in new issue