0

I have a class that has these initialized ArrayList containing information read in from a file. Once I created these I'm calling multiple method calls for the given category and trying to separate into groups of projects ( the numbers ) and 3 judges to each group. NOT repeating. Within the Judges array list it contains the judges name, the # of categories they would like to use (which I'm using as a priority... yes I know I could use different data structures), and the categories.

I'm having trouble when I read in a group project adding it to the newGroups and then trying to remove them from the original ArrayList given. In the same way I am trying to do the same for the Judges..

I hope this helps and I'm being as clear as I can. As well as providing as much information as possible. Please let me know if you have any questions.

thanks in advance.

private static ArrayList<ArrayList<String>> Judges = new ArrayList<ArrayList<String>>();
private static ArrayList<String> Chemistry = new ArrayList<String>();

groups(Chemistry, Chem, "Chemistry");

public static void groups(ArrayList<String> category,int projects, String name){
    
        ArrayList<String> newGroup = new ArrayList<String>();
        int groups;
        if (projects % 6 != 0) {
            groups = (projects / 6) + 1;
        } else {
            groups = projects / 6;
        }
        // int numJudges = groups * 3;  I'm not sure I need to have this in this 
        //method since I am adding a call to selectJudges

        for(int i = 1;i <= groups;i++){
            for(int j = 0;j <= 5;j++){
                if(category.isEmpty() != true){
                    newGroup.add(category.get(0));
                    category.remove(0);
                    category.trimToSize();
                }
            }
            selectJudges(newGroup,name);
            //added to verify this method is working correctly.
            System.out.println(name + "_" + i + newGroup); 
        }
    }

    // judges should be implemented just like the newGroup
    // Also print write to output stream while selecting judges.
    public static void selectJudges(ArrayList<String> judges,String name){

        ArrayList<String> assigned = new ArrayList<String>();
        // Still working on this method.
        //output it happening but not sure how to correct...
        for(int i = 0; i < 3; i++){
            for(int j = 0; j < Judges.size(); j++){
                if (Judges.get(j).contains(name) && Judges.get(j).contains("1")){
                    assigned.add(Judges.get(j).get(0));
                    Judges.remove(j);
                    Judges.trimToSize();
                    break;
                } else if(Judges.get(j).contains(name) && Judges.get(j).contains("2")){
                    assigned.add(Judges.get(j).get(0));
                    Judges.remove(j);
                    Judges.trimToSize();
                    break;
                } else if(Judges.get(j).contains(name) && Judges.get(j).contains("3")){
                    assigned.add(Judges.get(j).get(0));
                    Judges.remove(i);
                    Judges.trimToSize();
                    break;
                } else if(Judges.get(j).contains(name) && Judges.get(j).contains("4")){
                    assigned.add(Judges.get(j).get(0));
                    Judges.remove(j);
                    Judges.trimToSize();
                    break;
                } else if(Judges.get(j).contains(name) && Judges.get(j).contains("5")){
                    assigned.add(Judges.get(j).get(0));
                    Judges.remove(j);
                    Judges.trimToSize();
                    break;
                } else {
                    assigned.add(Judges.get(j).get(0));
                    Judges.remove(j);
                    Judges.trimToSize();
                    break;
                }
            }
        }
        System.out.println(assigned);
    }
mattgcf
  • 33
  • 6

0 Answers0