//randomly assigns pairs of students // Chris Kairalla 2007 // modified 2012 String[] students = { "Alexandra Coym", "Christina Polcari", "Edward Button", "Erika Maher", "Jorge Brake", "Peter Terezakis", "Rafael Gross Brown", "Tarana Gupta", "Tianran Qian", "Vitor Freire", "Wyna Liu", "Yolanda Zaragoza" }; //keeps track of whether a student has been picked. same size as students array boolean[] picked = new boolean[students.length]; boolean isFirstOfPair = true; void setup(){ //this is all text so setup isn't necessary. } void draw(){ //pick a random number between 0 and amount of students int pick = int(random(students.length)); //check if student has already been picked. if not... if (picked[pick] == false){ if (isFirstOfPair == true){ print(students[pick]+ " and "); } else { println(students[pick] + "."); } isFirstOfPair = !isFirstOfPair; //switch to opposite picked[pick] = true; } //see if everyone has been picked. go thorough the picked list and see if //there are any "falses". boolean noMore = true; for (int i = 0; i < picked.length; i++){ if (picked[i] == false){ noMore = false; } } //if there's no more students to pick then we're done. Stop looping the draw. if (noMore == true){ println("all done!"); noLoop(); } }