-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNbaFantasyCenter.java
More file actions
285 lines (210 loc) · 9.78 KB
/
Copy pathNbaFantasyCenter.java
File metadata and controls
285 lines (210 loc) · 9.78 KB
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
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package nbafantasycenter;
import java.io.Serializable;
import java.util.LinkedList;
/**
*
* @author JackHotaling
*/
public class NbaFantasyCenter implements Serializable {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
NbaFantasyCenter n = new NbaFantasyCenter();
LogInOrRegGUI l = new LogInOrRegGUI();
l.setVisible(true);
//test data for login:
//NbaFantasyCenter.addUser("Jack", "Hotaling", "jackhotalufl.edu", "Password1");
}
private static LinkedList<Player> hisPlayerSimStats = new LinkedList<>();
public static LinkedList<Player> getHisPlayerSimStats(){
return hisPlayerSimStats;
}
public static void setHisPlayerSimStats(LinkedList<Player> h){
hisPlayerSimStats = h;
}
public static void addSimStatsList(Team[] teamList) {
for (Team team : teamList) {
for (Player player : team.getPlayerArray()) {
hisPlayerSimStats.add(player);
}
}
System.out.print("\n\n\n"+hisPlayerSimStats.get(1).getPlayerName());
}
static Player temp;
public static void rankPlayers() {
for (int i = 0; i < hisPlayerSimStats.size(); i++) {
System.out.print(hisPlayerSimStats.get(i).getPlayerName());
if (hisPlayerSimStats.get(i) != null){
temp.equals(hisPlayerSimStats.get(i));
}
for (int j = 1; j < (hisPlayerSimStats.size() - i); j++) {
if (((Pfrontcourt) hisPlayerSimStats.get(j)).getPerformPoints() >= hisPlayerSimStats.get(j - 1).getPerformPoints()) {
temp = hisPlayerSimStats.get(j);
hisPlayerSimStats.get(j).equals(hisPlayerSimStats.get(j - 1));
hisPlayerSimStats.get(j - 1).equals(temp);
}
}
}
}
private static LinkedList<Player> players = new LinkedList<>();
public static LinkedList<Player> getPlayers() {
return players;
}
private static LinkedList<User> users = new LinkedList<>();
private static LinkedList<League> allHistoricalLeagues = new LinkedList<>();
private static User currentUser;
private static User lastLoggedIn;
public static User getLastUserAdded(){
return users.getLast();
}
public static void setCurrentUser(User user){
currentUser = user;
System.out.print("\n\n\n||Current User:" + user.getFirstName());
}
public static User getCurrentUser(){
return currentUser;
}
public static LinkedList<User> getAllUsers() {
return users;
}
public static User getLastLoggedIn(){
return lastLoggedIn;
}
private static LinkedList<League> leagues = new LinkedList<>();
private static League currentLeague;
//write
public static void setLeagues(LinkedList<League> leagues1) { leagues = leagues1; }
public static void setUsers(LinkedList<User> user1) { users = user1; }
public static void setHistoricalLeagues(LinkedList<League> leagues2) { allHistoricalLeagues = leagues2; }
public static LinkedList<League> getAvailableLeagues(){
//+leagues current user is not a part of
LinkedList<League> availableLeagues = new LinkedList<>();
for(int i = 0; i < leagues.size(); i++){
if(leagues.get(i) != null){
//MONITOR LIST OF LEAGUES
//nbafantasycenter.User cannot be cast to nbafantasycenter.League?????
// System.out.print("\nAVAILABLE LEAGUE LIST***: "+leagues.get(i).getLeagueName());
if(leagues.get(i).getLeagueStatus().equals("Awaiting Users")){
User[] leagueMembers = leagues.get(i).getLeagueMembers();
//for(int e = 0; e<leagueMembers.length; e++) { ----- loop logic???
if (leagueMembers[0] != currentUser && leagueMembers[1] != currentUser &&
leagueMembers[2] != currentUser && leagueMembers[3] != currentUser &&
leagueMembers[4] != currentUser && leagueMembers[5] != currentUser){
availableLeagues.add(leagues.get(i));
}
//}
//availableLeagues.add(leagues.get(i));
}
}
}
return availableLeagues;
}
public static League getAvailableLeagueByName(String leagueName){
LinkedList<League> availableLeagues = getAvailableLeagues();
for(int i = 0; i<availableLeagues.size(); i++){
if (availableLeagues.get(i).getLeagueName().equals(leagueName)){
return availableLeagues.get(i);
}
}
return availableLeagues.get(0); // INCORRECT LOGIC!!!!!!!!!!!!!!!!!!!!
}
public static League[] getMyLeagues(){
League[] leagues = currentUser.getUserLeagueList();
// if (leagues[2] != null){
// String leagueName = leagues[2].getLeagueName();
// System.out.print("NBA Fantasy Center league in element 3: " + leagueName);
// }
//System.out.print("NBA Fantasy Center league in element 3: " + leagueName);
return currentUser.getUserLeagueList();
}
public static LinkedList<League> getAllLeagues() {
return leagues;
}
public static LinkedList<League> getAllHistoricalLeagues() {
return allHistoricalLeagues;
}
public static void addUser(String firstName, String lastName, String email, String password) {
User u = new User(firstName, lastName, email, password);
users.add(u);
//addToUserList(u);
}
public static void addLeague(String leagueName, Double buyIn) {
League l = new League(leagueName, buyIn);
leagues.add(l);
//add to list
//assign to user
currentUser.addLeagueToUserLeagueList(l);
}
// addTeam in League class??
//add NBA player types
// public static void addPlayer(String name, String nbaTeam, Double avgPoints, Double avgRebounds, Double avgAssists, Double avgSteals, Double avgBlocks, Double avgTurnovers, Double avgFouls) {
// Player p = new Player(name, nbaTeam, avgPoints, avgRebounds, avgAssists, avgSteals, avgBlocks, avgTurnovers, avgFouls);
// players.add(p);
// }
public static void addPguard(Double turnAssistsRatio, String name, String nbaTeam, Double avgPoints, Double avgRebounds, Double avgAssists, Double avgSteals, Double avgBlocks, Double avgTurnovers, Double avgFouls, int nbaPts) {
Player p = new Pguard(turnAssistsRatio, name, nbaTeam, avgPoints, avgRebounds, avgAssists, avgSteals, avgBlocks, avgTurnovers, avgFouls, nbaPts);
players.add(p);
}
public static void addPfrontcourt(Double offRebRatio, String name, String nbaTeam, Double avgPoints, Double avgRebounds, Double avgAssists, Double avgSteals, Double avgBlocks, Double avgTurnovers, Double avgFouls, int nbaPts) {
Player p = new Pfrontcourt(offRebRatio, name, nbaTeam, avgPoints, avgRebounds, avgAssists, avgSteals, avgBlocks, avgTurnovers, avgFouls, nbaPts);
players.add(p);
}
public static Player searchPlayer(int i){
return players.get(i);
}
//public static void assignLeagueToUser??????
//boolean?
public static boolean logIn(String email, String password) {
String e = email; String p = password;
for(int i = 0; i < users.size(); i++) {
if(e.equals(users.get(i).getEmail())){
//System.out.print("matching user!");
if(p.equals(users.get(i).getPassword())){
lastLoggedIn = users.get(i);
return true;
}
}
}
return false;
}
//public static void addUserToList
public static League getCurrentUsersLeagueRefWithName(String leagueName) {
League[] currentUsersLeagues = currentUser.getUserLeagueList();
//
//System.out.print("\n%%%%%%%"+currentUser.getFirstName());
//System.out.print("%%%%%%%"+currentLeague);
for (int i = 0; i < currentUsersLeagues.length; i++){
//
if (currentUsersLeagues[i] != null) {
// System.out.print(" !@#"+currentUsersLeagues[i].getLeagueName());
if (currentUsersLeagues[i].getLeagueName().equals(leagueName)){
return currentUsersLeagues[i];
}
}
}
return currentUsersLeagues[0]; // INCORRECT LOGIC!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
}
public static League getHistLeagueRefWithName(String leagueName) {
for (int i = 0; i < allHistoricalLeagues.size(); i++){
//
if (allHistoricalLeagues.get(i) != null) {
// System.out.print(" !@#"+currentUsersLeagues[i].getLeagueName());
if (allHistoricalLeagues.get(i).getLeagueName().equals(leagueName)){
return allHistoricalLeagues.get(i);
}
}
}
return allHistoricalLeagues.get(0); // INCORRECT LOGIC!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
}
public static void concludeLeague(League finishedLeague){
System.out.print(finishedLeague.getLeagueName());
allHistoricalLeagues.add(finishedLeague);
}
}