Write a complete method at the client level called countGrea
Write a complete method at the client level called countGreaterThan.
The method counts how many items in a bag are greater than some number.
For example, if a bag contains (8, 9, 6, 3, 8, 6, 1) and you invoke the method with number = 3, the method will return 5 because there are 5 numbers greater than 3 in the bag (the 8, 9, 6, 8 and 6).
The bag should not be altered when the method completes.
The method header is:
public int counterGreaterThan(BagInterface<Integer> bag, int number)
For this question, you are writing code at the client level. This means you do not know how the bag is implemented.
Use any of the following BagInterface methods to answer the question below.
Note that toArray is not listed and should not be used in your solution.
public boolean add(T newEntry)
 public boolean isEmpty()
 public boolean contains(T anObject)
 public T remove()
 public boolean remove(T anEntry)
 public int getFrequencyOf(T anEntry)
 public int getCurrentSize()
 public void clear()
Solution
/**
    * method counts how many items in a bag are greater than some number
    *
    * @param bag
    * @param number
    * @return
    */
    public int counterGreaterThan(BagInterface<Integer> bag, int number) {
        int count = 0;
        for (Integer i : (SBag<Integer>) bag) {
            if (i > number)
                count++;
       }
        return count;
    }

