forked from Group00000011/UwoSurvivorPool
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBonusQuestion.java
More file actions
121 lines (109 loc) · 3 KB
/
Copy pathBonusQuestion.java
File metadata and controls
121 lines (109 loc) · 3 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/**
* BonusQuestion class creates a bonus question for a round of the survivor pool
*
* @author Manor Freeman, Hazel Rivera, Martin Grabarczyk, Liam Corrigan, Jeff
* Westaway, Delerina Hill
*
*/
public class BonusQuestion {
// Attributes
private String question;
private String[] answers;
private String correctAnswer;
/**
* Constructor for objects of the class BonusQuestion that initializes the
* question, answers, and correct answer of the bonus question
*
* @param question
* The question of the bonus question
* @param answers
* The possible answers of the bonus question
* @param correctAnswer
* The correct answer to the bonus question
*/
public BonusQuestion(String question, String[] answers, String correctAnswer) {
this.question = question;
this.answers = answers;
this.correctAnswer = correctAnswer;
}
// Accessor methods
/**
* Gets the question of the bonus question
*
* @return the question of the bonus question
*/
public String getQuestion() {
return this.question;
}
/**
* Gets the possible answers to the bonus question
*
* @return An array storing the possible answers to the bonus question
*/
public String[] getAnswers() {
return this.answers;
}
/**
* Gets the correct answer to the bonus question
*
* @return the correct answer to the bonus question
*/
public String getCorrectAnswer() {
return this.correctAnswer;
}
// Mutator methods
/**
* Sets the question of the bonus question object
*
* @param question
* the question of the bonus question object
**/
public void setQuestion(String question) {
this.question = question;
}
/**
* Sets the possible answers of the bonus question object
*
* @param answers
* an array of the possible answers to the question
*/
public void setAnswers(String answers[]) {
this.answers = answers;
}
/**
* Sets the correct answer of the bonus question object
*
* @param correctAnswer
* The correct answer of the bonus question object
*/
public void setCorrectAnswer(String correctAnswer) {
this.correctAnswer = correctAnswer;
}
// Other methods
/**
* Returns true if the specified answer is the correct answer to the
* question, otherwise returns false
*
* @param answer
* The player's answer to the bonus question
* @return true if the answer matches the correct answer of the bonus
* question, otherwise false
*/
public boolean answerQuestion(String answer) {
if (this.correctAnswer.equals(answer))
return true;
else
return false;
}
/**
* Returns true if the question is a multiple choice question, otherwise
* returns false
*
* @return true if the question is multiple choice, otherwise returns false
*/
public boolean isMultipleChoice() {
if (this.answers.length > 1)
return true;
return false;
}
}