import java.util.*;

public class Rules
{
    public static final String BAGS = "bags";
    public static final String BAGS_CONTAINS = "bags contain";
    public static final String NO_BAGS = " no other bags";
    public static final String CONTAINS = "contain";
    public static final String SEPARATOR = ",";
    public static final String TERMINATOR = ".";

    public Rules (boolean debug)
    {
        _debug = debug;
    }

    public Inventory parse (String dataFile)
    {
        Vector<String> rules = Util.loadData(dataFile, _debug);
        Inventory inv = new Inventory(_debug);
        Enumeration<String> iter = rules.elements();
        boolean error = false;

        while (iter.hasMoreElements() && !error)
        {
            String line = iter.nextElement();
            int index = line.indexOf(BAGS_CONTAINS);  // name of bag

            if (index != -1)
            {
                String bagColour = line.substring(0, index);
                Bag theBag = new Bag(bagColour);

                inv.add(theBag);

                String contents = line.substring(index + BAGS_CONTAINS.length());
                
                if (!contents.equals(NO_BAGS))
                {
                    index = 0;

                    while (index < contents.length())
                    {

                    }
                }
            }
            else
                error = true;
        }

        return inv;
    }

    private boolean _debug;
}
@@ -1061,19 +1061,19 @@
 ing cont
-ent
+ain
 s = line
@@ -1116,32 +1116,16 @@
 gth());%0A
-                
 %0A       
@@ -1142,19 +1142,19 @@
 f (!cont
-ent
+ain
 s.equals
@@ -1253,19 +1253,19 @@
 x %3C cont
-ent
+ain
 s.length
@@ -1294,79 +1294,357 @@
   %7B%0A
-%0A                    %7D%0A                %7D%0A            %7D%0A            else
+                        int temp = contains.indexOf(Rules.SEPARATOR, index);%0A%0A                        if (temp != -1)%0A                        %7B%0A                            %0A                        %7D%0A                    %7D%0A                %7D%0A            %7D%0A            else%0A            %7B%0A                System.out.println(%22Error, no bag name found!%22);%0A
 %0A   
@@ -1670,16 +1670,30 @@
 = true;%0A
+            %7D%0A
         

Update Rules.java