-
Notifications
You must be signed in to change notification settings - Fork 0
/
Category.java
52 lines (42 loc) · 901 Bytes
/
Category.java
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
44
45
46
47
48
49
50
51
52
package jiuyangw_CSCI201L_Assignment1;
import java.util.ArrayList;
public class Category {
// Member vars
private ArrayList<Question> mQuestions;
private String mName;
// Member functions
Category(String name){
mName = name;
mQuestions = new ArrayList<Question>();
}
public String getName(){
return mName;
}
public Question getQuestion(int point){
for(Question q : mQuestions){
if(q.getPoint() == point){
return q;
}
}
return (new Question(-100, "", ""));
}
public ArrayList<Question> getQuestions(){
return mQuestions;
}
public void addQuestion(Question q){
mQuestions.add(q);
}
public int getQuestionNumber(){
return mQuestions.size();
}
public boolean pointIncluded(int point){
boolean included = false;
for(Question q : mQuestions){
if(q.getPoint() == point){
included = true;
break;
}
}
return included;
}
}