-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStudent.java
More file actions
39 lines (33 loc) · 993 Bytes
/
Student.java
File metadata and controls
39 lines (33 loc) · 993 Bytes
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
import java.util.ArrayList;
public class Student{
public String id;
public ArrayList<Integer> answer = new ArrayList<>();
//default constructor
public Student(String id){
this.id = id;
}
// sets the answer the student chooses for single choice question
public void setAnswer(SingleChoiceQuestion question, int answer){
if(this.answer.size() > 0){
this.answer.remove(0);
}
this.answer.add(answer);
}
// sets the answer the student chooses for multichoice question
public void setAnswer(MultiChoiceQuestion question, int... answers){
for(int i = 0; i < this.answer.size(); i++){
this.answer.remove(i);
}
for(int answer : answers){
this.answer.add(answer);
}
}
// gets the students answer
public ArrayList<Integer> getAnswer(){
return answer;
}
// gets the students id
public String getID(){
return id;
}
}