3 import java.io.Serializable;
4 import java.util.Vector;
6 import javax.persistence.CascadeType;
7 import javax.persistence.Entity;
8 import javax.persistence.FetchType;
9 import javax.persistence.GeneratedValue;
10 import javax.persistence.Id;
11 import javax.persistence.OneToMany;
12 import javax.xml.bind.annotation.XmlAccessType;
13 import javax.xml.bind.annotation.XmlAccessorType;
14 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
16 @SuppressWarnings("serial")
17 @XmlAccessorType(XmlAccessType.FIELD)
19 public class Question implements Serializable {
22 @XmlJavaTypeAdapter(IntegerAdapter.class)
24 private Integer questionNumber;
25 private String question;
26 private float betMinimum;
27 private String result;
28 @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.PERSIST)
29 private Vector<Forecast> forecasts = new Vector<Forecast>();
31 private boolean hasResult;
33 public boolean hasResult() {
37 public void hasResult(boolean hasResult) {
38 this.hasResult = hasResult;
45 public Question(Integer queryNumber, String query, float betMinimum, Event event) {
47 this.questionNumber = queryNumber;
48 this.question = query;
49 this.betMinimum = betMinimum;
54 public Question(String query, float betMinimum, Event event) {
56 this.question = query;
57 this.betMinimum = betMinimum;
64 * Get the number of the question
66 * @return the question number
68 public Integer getQuestionNumber() {
69 return questionNumber;
73 * Set the bet number to a question
75 * @param questionNumber to be setted
77 public void setQuestionNumber(Integer questionNumber) {
78 this.questionNumber = questionNumber;
82 * Get the question description of the bet
84 * @return the bet question
87 public String getQuestion() {
92 * Set the question description of the bet
94 * @param question to be setted
96 public void setQuestion(String question) {
97 this.question = question;
101 * Get the minimun ammount of the bet
103 * @return the minimum bet ammount
106 public float getBetMinimum() {
111 * Get the minimun ammount of the bet
113 * @param betMinimum minimum bet ammount to be setted
116 public void setBetMinimum(float betMinimum) {
117 this.betMinimum = betMinimum;
121 * Get the result of the query
123 * @return the the query result
125 public String getResult() {
130 * Get the result of the query
132 * @param result of the query to be setted
135 public void setResult(String result) {
136 this.result = result;
140 * Get the event associated to the bet
142 * @return the associated event
144 public Event getEvent() {
149 * Set the event associated to the bet
151 * @param event to associate to the bet
153 public void setEvent(Event event) {
157 public Vector<Forecast> getForecasts() {
161 public void setForecasts(Vector<Forecast> forecasts) {
162 this.forecasts = forecasts;
165 public Forecast addForecast(String forecast, float fee) {
166 Forecast f = new Forecast(forecast, fee, this);
171 public Forecast addForecast(Forecast forecast) {
172 forecasts.add(forecast);
176 public boolean DoesForecastExists(String forecast) {
177 for (Forecast f : this.getForecasts()) {
178 if (f.getForecast().compareTo(forecast) == 0)
185 public String toString() {
186 return questionNumber + "; " + question + "; " + Float.toString(betMinimum) + " ➪ " + event.getDescription();