public String toString()
    {
        String result = "";
        boolean has999 = false;
        for (int branch = 0; branch < numBranches; branch++)
        {
            result += "Branch " + branch + "\n";
            for (Component comp : components)
            {
                if (comp.getBranch() == 999)
                {
                    has999 = true;
                }
                if (comp.getBranch() == branch)
                {
                    result += comp.toString() + "\n";
                }
            }
            result += "\n";
        }
        if (has999)
        {
            result += "Branch 999\n";
            for (Component comp : components)
            {
                if (comp.getBranch() == 999)
                {
                    result += comp.toString() + "\n";
                }
            }
        }
        result += "\n";
        return result;
    }