1
2 package hoplugins.teamAnalyzer.report;
3
4 import hoplugins.teamAnalyzer.vo.PlayerPerformance;
5
6
7 /***
8 * A Report class used for collect data on a specific spot on the field
9 *
10 * @author <a href=mailto:draghetto@users.sourceforge.net>Massimiliano Amato</a>
11 */
12 public class Report {
13
14
15 /*** The rating achieved */
16 private double rating;
17
18 /*** Number of appearance */
19 private int appearance;
20
21 /*** The player id */
22 private int playerId;
23
24 /*** The position who has the player that played in the spot, defender or extra midfielder */
25 private int position;
26
27 /*** The spot place on the lineup */
28 private int spot;
29 private int status;
30
31
32
33 /***
34 * Creates a new Report object.
35 *
36 * @param pp PlayerPerformance for which the report has to be built
37 */
38 public Report(PlayerPerformance pp) {
39 this.spot = pp.getId();
40 this.position = pp.getPositionCode();
41 this.playerId = pp.getSpielerId();
42
43 this.status = pp.getStatus();
44 }
45
46 /***
47 * Creates a new Report object.
48 */
49 public Report() {
50 }
51
52
53
54 /***
55 * Document Me!
56 *
57 * @param i
58 */
59 public void setAppearance(int i) {
60 appearance = i;
61 }
62
63 /***
64 * Document Me!
65 *
66 * @return
67 */
68 public int getAppearance() {
69 return appearance;
70 }
71
72 /***
73 * DOCUMENT ME!
74 *
75 * @param i
76 */
77 public void setPlayerId(int i) {
78 playerId = i;
79 }
80
81 /***
82 * DOCUMENT ME!
83 *
84 * @return
85 */
86 public int getPlayerId() {
87 return playerId;
88 }
89
90 /***
91 * DOCUMENT ME!
92 *
93 * @param i
94 */
95 public void setPosition(int i) {
96 position = i;
97 }
98
99 /***
100 * DOCUMENT ME!
101 *
102 * @return
103 */
104 public int getPosition() {
105 return position;
106 }
107
108 /***
109 * Document Me!
110 *
111 * @param d
112 */
113 public void setRating(double d) {
114 rating = d;
115 }
116
117 /***
118 * Document Me!
119 *
120 * @return
121 */
122 public double getRating() {
123 return rating;
124 }
125
126 /***
127 * Document Me!
128 *
129 * @param i
130 */
131 public void setSpot(int i) {
132 spot = i;
133 }
134
135 /***
136 * Document Me!
137 *
138 * @return
139 */
140 public int getSpot() {
141 return spot;
142 }
143
144 /***
145 * Add another performance to the Report, updating appearance and average rating the rest has
146 * to be updated in child classes
147 *
148 * @param pp
149 */
150 public void addPerformance(PlayerPerformance pp) {
151 appearance++;
152 rating = ((rating * (appearance - 1)) + pp.getRating()) / appearance;
153 }
154
155 /***
156 * toString methode: creates a String representation of the object
157 *
158 * @return the String representation
159 */
160 public String toString() {
161 StringBuffer buffer = new StringBuffer();
162
163 buffer.append("numberAppearance = " + appearance);
164 buffer.append(", averageRating = " + rating);
165 buffer.append(", spot = " + spot);
166 buffer.append(", position = " + position);
167
168 return buffer.toString();
169 }
170 }