Iteración 3(Versión sin idiomas)
[ISBets21MAUBRY] / eclipse-workspace / ISBets21MAUBRY / src / main / java / domain / Forecast.java
1 package domain;
2
3 import java.util.Vector;
4
5 import javax.persistence.CascadeType;
6 import javax.persistence.Entity;
7 import javax.persistence.FetchType;
8 import javax.persistence.GeneratedValue;
9 import javax.persistence.Id;
10 import javax.persistence.OneToMany;
11 import javax.persistence.TableGenerator;
12 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
13
14 @Entity
15 public class Forecast {
16
17         @GeneratedValue()
18         @Id
19         @XmlJavaTypeAdapter(IntegerAdapter.class)
20         private Integer forecastNumber;
21         private String forecast;
22         private float fee;
23         private Question question;
24         @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.PERSIST)
25         private Vector<Bet> bets = new Vector<Bet>();
26         private boolean winnerf;
27
28         public boolean isWinnerf() {
29                 return winnerf;
30         }
31
32         public void setWinnerf(boolean winnerf) {
33                 this.winnerf = winnerf;
34         }
35
36         public Forecast() {
37                 super();
38         }
39
40         public Forecast(int n, String s, float f, Question q) {
41                 //super();
42                 forecast = s;
43                 question = q;
44                 fee = f;
45                 forecastNumber = n;
46         }
47
48         public Forecast(String s, float f, Question q) {
49                 super();
50                 forecast = s;
51                 fee = f;
52                 question = q;
53
54         }
55
56         public String getForecast() {
57                 return forecast;
58         }
59
60         public void setForecast(String s) {
61                 forecast = s;
62         }
63
64         public Question getQuestion() {
65                 return question;
66         }
67
68         public void setQuestion(Question q) {
69                 question = q;
70         }
71
72         public Integer getForecastNumber() {
73                 return forecastNumber;
74         }
75
76         public void setForecastNumber(int n) {
77                 forecastNumber = n;
78         }
79
80         public float getFee() {
81                 return fee;
82         }
83
84         public void setFee(float f) {
85                 fee = f;
86         }
87
88         @Override
89         public String toString() {
90                 return "Forecast: " + forecast + "; " + fee + " ➪ " + question.toString();
91         }
92
93         public Bet addBet(Forecast forecast, RegularUser u, float amount) {
94                 Bet b = new Bet(this, u, amount);
95                 bets.add(b);
96                 return b;
97         }
98
99         public Vector<Bet> getBets() {
100                 return bets;
101         }
102
103         public void setForecasts(Vector<Bet> bets) {
104                 this.bets = bets;
105         }
106 }