1
2
3
4
5 package spellcast.questions;
6
7 import java.io.Serializable;
8 import java.util.ArrayList;
9 import java.util.List;
10
11 import org.apache.commons.lang.builder.ToStringBuilder;
12 import org.apache.log4j.Logger;
13
14 import spellcast.model.Id;
15
16 /***
17 * Default Implementation of <code>IQuestion</code>.
18 *
19 * @author Barrie Treloar
20 * @version $Revision: 1.1 $
21 */
22 public abstract class Question implements Serializable, IQuestion {
23 /***
24 * serialVersionUID.
25 */
26 private static final long serialVersionUID = 1L;
27
28 private Id id;
29 private String question;
30 private Object answer;
31 private List<Object> answers;
32
33 private static Logger logger = Logger.getLogger("game");
34
35 protected Question(final String theQuestion, final List<? extends Object> theAnswers) {
36 id = Id.createId();
37 question = theQuestion;
38 answers = new ArrayList<Object>(theAnswers);
39 answer = theAnswers.get(0);
40 }
41
42 /***
43 * Get the value of ID.
44 *
45 * @return value of ID.
46 */
47 private Id getID() {
48 return id;
49 }
50
51 /***
52 * {@inheritDoc}
53 */
54 public final String getQuestion() {
55 return question;
56 }
57
58 /***
59 * {@inheritDoc}
60 */
61 public final Object getAnswer() {
62 return answer;
63 }
64
65 /***
66 * {@inheritDoc}
67 */
68 public final void setAnswer(final Object theAnswer) {
69 answer = theAnswer;
70 }
71
72 /***
73 * {@inheritDoc}
74 */
75 public final List<Object> getAnswers() {
76 return new ArrayList<Object>(answers);
77 }
78
79 public final String toString() {
80 return ToStringBuilder.reflectionToString(this);
81 }
82
83
84 }