-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSelectionGroup.java
More file actions
43 lines (43 loc) · 1.2 KB
/
SelectionGroup.java
File metadata and controls
43 lines (43 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
public class SelectionGroup(){
public ArrayList<Student> students;
private ArrayList<String> names;
private ArrayList<String> selected;
private String groupname;
public int score = 0;
private int randomnumber;
public SelectionGroup(String name){
groupname = name;
names = new Arraylist<Student>;
}
public SelectionGroup(ArrayList<Student> currnames){
names = currnames;
}
public void addStudent(Student student){
students.add(student);
names.add(student.getName());
}
public void removeStudent(Student student){
for(int i=0;i<names.length();i++){
if((names.get(i)).equals(student.name));
names.remove(i);
student.remove(i);
break;
}
}
}
public ArrayList<String> listAllStudents(){
return names;
}
public ArrayList<String> pickRandomSubgroup(int numstudents){
int numberofstudents = students.length();
for(int i=0;i<selected.length();i++) selected.remove(i);
for(int i=0;i<numStudents;i++){
randomnumber = Math.random()*numstudents)
selected.add(names.get(randomnumber));
names.remove(randomnumber);
students.remove(randomnumber);
numberofstudents--;
}
return selected;
}
}