-
Notifications
You must be signed in to change notification settings - Fork 0
/
FAQ.java
106 lines (93 loc) · 2.33 KB
/
FAQ.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
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
import java.util.ArrayList;
/**
* A FAQ
* @author: J TEA: Tessa Neal, Eve Blom, Anna Phan, and Jacqueline Askey
*/
public class FAQ {
private String question;
private ArrayList<String> answers = new ArrayList<String>();
/**
* Creates a FAQ
* @param question a question
* @param answers an array list of answers
*/
public FAQ(String question, ArrayList<String> answers) {
this.question = question;
this.answers.addAll(answers);
}
/**
* Creates a FAQ
* @param question a question
* @param answer an answer
*/
public FAQ(String question, String answer) {
this.question = question;
this.answers.add(answer);
}
/**
* Creates a FAQ
* @param question a question
* @param answer an array of answers
*/
public FAQ(String question, String[] answer) {
this.question = question;
for (int i = 0; i< answers.size(); i++){
answers.add(new String(answer[i]));
}
}
/**
* Creates an FAQ from an FAQ
* @param faq an FAQ
*/
public FAQ(Question faq) {
this.question = faq.getQuestion();
this.answers = faq.getAnswers();
}
/**
* Sets the question of FAQ
* @param question a question
*/
public FAQ(String question) {
this.question = question;
}
/**
* Adds an answer to the answers array list
* @param answer an answer
*/
public void answerQuestion(String answer) {
answers.add(answer);
}
/**
* Returns a question
* @return a question
*/
public String getQuestion(){
return question;
}
/**
* Returns an ArrayList of answers
* @return an ArrayList of answers
*/
public ArrayList<String> getAnswers(){
return answers;
}
/**
* Adds an answer to the answers array list
* @param answer an answer
*/
public void addAnswer(String answer) {
answers.add(answer);
}
/**
* Returns details of the FAQ
* @return A string representation of a FAQ
*/
public String toString() {
String result = "Question: " + question + "\nAnswers: \n";
for(String answer: answers) {
result += answer;
result += "\n";
}
return result;
}
}