import java.util.ArrayList;

interface IFilter
{
	 Boolean Filter(String str);
	
}

class LowerBoundFilter implements IFilter
{
	char LowerBoundary;
	public LowerBoundFilter(String Boundary)
	{
		LowerBoundary = Boundary.charAt(0);	
	}
	public Boolean Filter(String str)
	{
		ArrayList<String> list = new ArrayList<String>();
		if (str.charAt(0) <  LowerBoundary )
			return false;
		return true;
	}
}


class UpperBoundFilter implements IFilter
{
	char UpperBoundary;
	public UpperBoundFilter(String Boundary)
	{
		UpperBoundary = Boundary.charAt(0);	
	}
	public Boolean Filter(String str)
	{
		ArrayList<String> list = new ArrayList<String>();
		if (str.charAt(0) >  UpperBoundary )
			return false;
		return true;
	}
}


class MyCollectionOfThreeWords 
{
	ArrayList<String> data = new ArrayList<String>();
	public void Fill (String[] ara)
	{
		for (String s : ara)
		{
			System.out.println("adding " +  s);
		}
	}
	
	public void Process (IFilter iflt)
	{
		for (int i = 0 ; i < data.size(); i++)
			if (!iflt.Filter (data.get(i) ) )
				data.remove(i);
	}
	
	public void Print()
	{
		for (String s : data)
			System.out.println(s);
	}
}

public class ObjectLab05
    {
	 //use the interface IFilter
    	public static void main(String[] args) 
        {

    		String[] ara = new String[] {"lingo", "radar", "camel"};
            MyCollectionOfThreeWords col = new MyCollectionOfThreeWords();
            col.Fill(ara);
  
            LowerBoundFilter f = new LowerBoundFilter("l");   //removing < l
            col.Process(f);  //the one and only one Process method
  
            UpperBoundFilter uf = new UpperBoundFilter("m");  //removing > m
            col.Process(uf);
            col.Print();
        }
    }
 
 
 
 /*
 
 adding lingo
 adding radar
 adding camel
 lingo

 */