我需要对“所有过滤器类”进行哪些更改?对于 MatchAllFilter 类,getName 方法应返回其 ArrayList 中所有过滤器名称的字符串,我不知道该怎么做。我还想知道如何在像深度这样的过滤器中使用 getName 方法?public interface Filter { public String getName(); public boolean satisfies(QuakeEntry qe);}public class DepthFilter implements Filter { private double depthMin; private double depthMax; private String fName; public DepthFilter(double min, double max, String name) { depthMin = min; depthMax = max; fName = name; } public boolean satisfies(QuakeEntry qe) { if (qe.getDepth() >= depthMin && qe.getDepth() <= depthMax) { return true; } return false; }}public class MatchAllFilter implements Filter { private ArrayList<Filter> filters; private String fName; public MatchAllFilter() { filters = new ArrayList<Filter>(); }public void addFilter(Filter f){ filters.add(f); public boolean satisfies(QuakeEntry qe) { for (Filter f : filters) { if (!f.satisfies(qe)) { // any of the filters criteria failed, then exit return false; } } return true; }}
添加回答
举报
0/150
提交
取消