-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRandomStats.java
383 lines (294 loc) · 11.7 KB
/
RandomStats.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
import java.util.*;
import java.io.*;
import java.lang.*;
import java.sql.*;
public class RandomStats
{
//RANDOMIZE STATS
public static void qbstats()
{
//Number of QB's
int numqb = 32;
//Stats for a QB
int[] qbTD;
int[] qbYards;
int[] qbInt;
//Points for QB
int[] qbTDpnts;
int[] qbYardspnts;
int[] qbIntpnts;
//Total points for QB
int[] qbtotal;
Random generator = new Random();
//Determine stats for all QBs and the points for those stats
int q;
for(q = 0; q <= numqb; q++)
{
qbTD[q] = generator.nextInt(5);
qbYards[q] = generator.nextInt(325);
qbInt[q] = generator.nextInt(3);
qbTDpnts[q] = qbTD[q] * 6;
qbYardspnts[q] = (qbYards[q]/25) * 1;
qbIntpnts[q] = qbInt[q] * (-2);
qbtotal[q] = qbTDpnts[q] + qbYardspnts[q] + qbIntpnts[q];
}
q=0;
while(q <= numqb)
{
updateWeekStatsQB(qbTD[q]\, qbYards[q], qbInt[q], qbtotal[q]);
q++;
}
}
public static void rbstats()
{
//Number of RB's
int numrb = 32;
//Stats for a RB
int []rbTD;
int []rbYards;
int []rbFumbles;
//Points for RB
int []rbTDpnts;
int []rbYardspnts;
int []rbFumblespnts;
//Total points for RB
int []rbtotal;
Random generator = new Random();
//Determine stats for all RBs and the points for those stats
int r;
for(r = 0; r <= numrb; r++)
{
rbTD[r] = generator.nextInt(5);
rbYards[r] = generator.nextInt(120);
rbFumbles[r] = generator.nextInt(1);
rbTDpnts[r] = rbTD[r] * 6;
rbYardspnts[r] = (rbYards[r]/10) * 1;
rbFumblespnts[r] = rbFumbles[r] * (-2);
rbtotal[r] = rbTDpnts[r] + rbYardspnts[r] + rbFumblespnts[r];
}
r=0;
while(r <= numrb)
{
updateWeekStatsRB(rbTD[r], rbYards[r], rbFumbles[r], rbtotal[r]);
r++;
}
}
public static void wrstats()
{
//Number of WR's
int numwr = 32;
//Stats for a WR
int []wrTD;
int []wrYards;
//Points for WR
int []wrTDpnts;
int []wrYardspnts;
//Total points for WR
int []wrtotal;
Random generator = new Random();
//Determine stats for all WRs and the points for those stats
int w;
for(w = 0; w <= numwr; w++)
{
wrTD[w] = generator.nextInt(3);
wrYards[w] = generator.nextInt(100);
wrTDpnts[w] = wrTD[w] * 6;
wrYardspnts[w] = (wrYards[w]/10) * 1;
wrtotal[w] = wrTDpnts[w] + wrYardspnts[w];
}
w=0;
while(w <= numwr)
{
updateWeekStatsWR(wrTD[w], wrYards[w], wrtotal[w]);
w++;
}
}
public static void testats()
{
//Number of TE's
int numte = 32;
//Stats for a TE
int []teTD;
int []teYards;
//Points for TE
int []teTDpnts;
int []teYardspnts;
//Total points for TE
int []tetotal;
Random generator = new Random();
//Determine stats for all TE's and the points for those stats
int t;
for(t = 0; t <= numte; t++)
{
teTD[t] = generator.nextInt(2);
teYards[t] = generator.nextInt(80);
teTDpnts[t] = teTD[t] * 6;
teYardspnts[t] = (teYards[t]/10) * 1;
tetotal[t] = teTDpnts[t] + teYardspnts[t];
}
t=0;
while(t <= numte)
{
updateWeekStatsTE(teTD[t], teYards[t], tetotal[t]);
t++;
}
}
public static void defstats()
{
//Number of DEF's
int numdef = 32;
//Stats for a DEF
int []pntsallowed;
int []turnovers;
int []sacks;
int []defTD;
//Points for DEF
int []pntsallowedpnts;
int []turnoverspnts;
int []sackspnts;
int []defTDpnts;
//Total points for DEF
int []deftotal;
Random generator = new Random();
//Determine stats for all DEFs and the points for those stats
int d;
for(d = 0; d <= numdef; d++)
{
turnovers[d] = generator.nextInt(3);
sacks[d] = generator.nextInt(3);
defTD[d] = generator.nextInt(1);
pntsallowed[d] = generator.nextInt(43) + 2;
turnoverspnts[d] = turnovers[d] * 2;
sackspnts[d] = sacks[d] * 2;
defTDpnts[d] = defTD[d] * 6;
if(pntsallowed[d] < 10)
{
pntsallowedpnts[d] = 4;
}
if(pntsallowed[d] >= 10 && pntsallowed[d] < 20)
{
pntsallowedpnts[d] = 2;
}
if(pntsallowed[d] >= 20 && pntsallowed[d] < 30)
{
pntsallowedpnts[d] = 0;
}
if(pntsallowed[d] >= 30 && pntsallowed[d] < 40)
{
pntsallowedpnts[d] = -2;
}
if(pntsallowed[d] >= 40)
{
pntsallowedpnts[d] = -4;
}
deftotal[d] = turnoverspnts[d] + sackspnts[d] + defTDpnts[d] + pntsallowedpnts[d];
}
d=0;
while(d <= numdef)
{
updateWeekStatsDEF(turnovers[d], sacks[d], defTD[d], pntsallowed[d], deftotal[d]);
d++;
}
}
public static void kstats()
{
//Number of K's
int numk = 32;
//Stats for K
int []lessfourtyFG;
int []greatfourtyFG;
int []lessFGmiss;
int []greatFGmiss;
int []PAT;
int []missPAT;
//Points for K
int []lessfourtyFGpnts;
int []greatfourtyFGpnts;
int []lessFGmisspnts;
int []greatFGmisspnts;
int []PATpnts;
int []missPATpnts;
//Total points for K
int []ktotal;
Random generator = new Random();
//Determine stats for all Ks and the points for those stats
int k;
for(k = 0; k <= numk; k++)
{
lessfourtyFG[k] = generator.nextInt(2);
greatfourtyFG[k] = generator.nextInt(1);
lessFGmiss[k] = generator.nextInt(1);
greatFGmiss[k] = generator.nextInt(1);
PAT[k] = generator.nextInt(4);
missPAT[k] = generator.nextInt(1);
lessfourtyFGpnts[k] = lessfourtyFG[k] * 3;
greatfourtyFGpnts[k] = greatfourtyFG[k] * 4;
lessFGmisspnts[k] = lessFGmiss[k] * (-2);
greatFGmisspnts[k] = greatFGmiss[k] * (-1);
PATpnts[k] = PAT[k] * 1;
missPATpnts[k] = missPAT[k] * (-1);
ktotal[k] = lessfourtyFGpnts[k] + greatfourtyFGpnts[k] + lessFGmisspnts[k] + greatFGmisspnts[k] + PATpnts[k] + missPATpnts[k];
}
k=0;
while(k <= numk)
{
updateWeekStatsK(lessfourtyFG[k], greatfourtyFG[k], lessFGmiss[k], greatFGmiss[k], PAT[k], missPAT[k], ktotal[k]);
k++;
}
}
//UPDATE WEEKLY STATS FOR PLAYERS
public static void updateWeekStatsQB(int td, int yds, int intcp, int points,String playerName)
{
Class.forName("com.mysql.jdbc.Driver");
//DON'T FORGET TO PUT THE USERNAME AND PASS FOR YOUR DRIVER CONNECTION TO THE DATABASE BELOW
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/");
Statement instruction = conn.createStatement();
//NEED TO FIGURE OUT HOW TO UPDATE ROW BY ROW
ResultSet result = instruction.executeQuery("UPDATE weeklystats w SET w.passTD="+td+",w.passYards="+yds+",w.interceptions="+intcp+",w.calpoints="+points+" WHERE w.name='"+playerName+"'" );
}
public static void updateWeekStatsRB(int td, int yds, int fmbl, int points,String playerName)
{
Class.forName("com.mysql.jdbc.Driver");
//DON'T FORGET TO PUT THE USERNAME AND PASS FOR YOUR DRIVER CONNECTION TO THE DATABASE BELOW
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/");
Statement instruction = conn.createStatement();
//NEED TO FIGURE OUT HOW TO UPDATE ROW BY ROW
ResultSet result = instruction.executeQuery("UPDATE weeklystats w SET w.rushTD="+td+",w.rushYards="+yds+",w.fumbles="+fmbl+",w.calpoints="+points+" WHERE w.name='"+playerName+"'");
}
public static void updateWeekStatsWR(int td, int yds, int points)
{
Class.forName("com.mysql.jdbc.Driver");
//DON'T FORGET TO PUT THE USERNAME AND PASS FOR YOUR DRIVER CONNECTION TO THE DATABASE BELOW
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/");
Statement instruction = conn.createStatement();
//NEED TO FIGURE OUT HOW TO UPDATE ROW BY ROW
ResultSet result = instruction.executeQuery("UPDATE weeklystats w SET w.receivingTD="+td+",w.receivingYards="+yds+",w.calpoints="+points+" WHERE w.name='"+playerName+"'");
}
public static void updateWeekStatsTE(int td, int yds, int points)
{
Class.forName("com.mysql.jdbc.Driver");
//DON'T FORGET TO PUT THE USERNAME AND PASS FOR YOUR DRIVER CONNECTION TO THE DATABASE BELOW
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/");
Statement instruction = conn.createStatement();
//NEED TO FIGURE OUT HOW TO UPDATE ROW BY ROW
ResultSet result = instruction.executeQuery("UPDATE weeklystats w SET w.receivingTD="+td+",w.receivingYards="+yds+",w.calpoints="+points+" WHERE w.name='"+playerName+"'");
}
public static void updateWeekStatsDEF(int to, int sack, int td, int allow, int points)
{
Class.forName("com.mysql.jdbc.Driver");
//DON'T FORGET TO PUT THE USERNAME AND PASS FOR YOUR DRIVER CONNECTION TO THE DATABASE BELOW
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/");
Statement instruction = conn.createStatement();
//NEED TO FIGURE OUT HOW TO UPDATE ROW BY ROW
ResultSet result = instruction.executeQuery("UPDATE weeklystats w SET w.turnovers="+to+",w.sacks="+sack+",w.defensiveTD="+td+",w.pointsallowed="+allow+", calpoints="+points+" w.name='"+playerName+"'");
}
public static void updateWeekStatsK(int l40, int g40, int ml40, int mg40, int pat, int mpat, int points)
{
Class.forName("com.mysql.jdbc.Driver");
//DON'T FORGET TO PUT THE USERNAME AND PASS FOR YOUR DRIVER CONNECTION TO THE DATABASE BELOW
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/");
Statement instruction = conn.createStatement();
//NEED TO FIGURE OUT HOW TO UPDATE ROW BY ROW
ResultSet result = instruction.executeQuery("UPDATE weeklystats w SET w.fieldgoalless40="+l40+",w.fieldgoalgreater40="+g40+",w.missedfieldgoaless40="+ml40+",w.missedfieldgoalgreater40="+mg40+",w.PAT="+pat+",w.missPAT="+mpat+",w.calpoints="+points+" WHERE w.name='"+playerName+"'");
}
}