import java.util.*;

public class Bag
{
    public Bag (String type)
    {
        this(type, 0);
    }

    public Bag (String type, int quantity)
    {
        _type = type.trim();
        _quantity = quantity;
        _contains = new Vector<Bag>();
    }
    
    public void add (Bag b)
    {
        _contains.add(b);
    }

    public boolean contains (Bag b)
    {
        return _contains.contains(b);
    }

    public final int quantity ()
    {
        return _quantity;
    }

    public String printRule ()
    {
        String str = this+" bags "+Rules.CONTAINS+" ";

        if (_contains.size() > 0)
        {
            Enumeration<Bag> iter = _contains.elements();

            while (iter.hasMoreElements())
            {
                Bag b = iter.nextElement();

                if (b._quantity > 0)
                {
                    str += b._quantity;
                }

                str += " "+b;

                if (iter.hasMoreElements())
                    str += Rules.SEPARATOR;
            }

            str += Rules.TERMINATOR;
        }
        else
            str += Rules.NO_BAGS;

        return str;
    }

    @Override
    public String toString ()
    {
        return _type;
    }

    @Override
    public int hashCode ()
    {
        return Objects.hash(_type);
    }

    @Override
    public boolean equals (Object obj)
    {
        if (obj == null)
            return false;

        if (this == obj)
            return true;
        
        if (getClass() == obj.getClass())
        {
            Bag temp = (Bag) obj;

            System.out.println("comparing "+_type+" and "+temp._type);
            
            return temp._type.equals(_type);
        }

        return false;
    }

    private String _type;
    private int _quantity;
    private Vector<Bag>_contains;
}
@@ -1580,92 +1580,8 @@
 j;%0A%0A
-            System.out.println(%22comparing %22+_type+%22 and %22+temp._type);%0A            %0A
     

Update Bag.java