Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I am working on a class assignment where I have a collection and it will be filt

ID: 3663914 • Letter: I

Question

I am working on a class assignment where I have a collection and it will be filtered out. For example, the filter class, which is an interface is one method (matches) which takes in T element.

In my FilterCollection class:

From there I have to override methods, such as size, add, addall, contains, remove, etc.

I need help with the size() method that returns the size of the filtered collection. I can only seem to return the size of the original collection.

public int size()
{
}

I am working on a class assignment where I have a collection and it will be filtered out. For example, the filter class, which is an interface is one method (matches) which takes in T element.

In my FilterCollection class:

  public class FilteredCollection<T> extends AbstractCollectionDecorator<T> {    Collection<T> filterCollection;  Filter<T> currentFilter;  private FilteredCollection(Collection<T> coll, Filter<T> filter) {      super(coll);      this.filterCollection = coll;      this.currentFilter = filter;  }      public static <T> FilteredCollection<T> decorate(Collection<T> coll, Filter<T> filter) {      return new FilteredCollection<T>(coll, filter);  }  

From there I have to override methods, such as size, add, addall, contains, remove, etc.

I need help with the size() method that returns the size of the filtered collection. I can only seem to return the size of the original collection.

public int size()
{
}

Explanation / Answer

Inorder to get the size of filtered collection, first you need to get the filtered collection by calling the method

it will be looking like :

public int size()
{

return (decorate(this.filterCollection,this.currentFilter)).size();
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote