lundi 27 avril 2020

distrubuting people to groups evenly based on userinput

ReadFile randomGenerate = new ReadFile();
        Input userNum = new Input();
        String classnum = userNum.fileToSelect();
        int lineNumber = randomGenerate.lineCounter(classnum);

        //number of students in classnum.txt

        ArrayList<String> people = randomGenerate.readPeople();
        //a string of names(first word on each row)

        int userPut = userNum.numInput();
        int maxNum = lineNumber/userPut;

Right not, I am reading off a txt file - the first word of each row which is the name of a person. I want to distribute this ArrayList of people into even groups, with the number of groups based on userinput.

int[] numbers = RandomNumbersWithoutRepetition(0, lineNumber, lineNumber);       
//an array of numbers IN ORDER

int[] randomNumbers = RandomizeArray(numbers);
//shuffles the array

I generated a set of numbers in order, and then shuffled them, which works fine.

But, my method of grouping people has been based off ifelse conditions which don't work so well. So is there an efficient method to put this ArrayList of names into user-desired groups?




Aucun commentaire:

Enregistrer un commentaire