-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMyTeam.java
121 lines (97 loc) · 2.94 KB
/
MyTeam.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
/**
* Program: My Team
* File: MyTeam.java
* Summary: Class that builds your selected team
* Author: Ronald Pearl
* Date: Aug 1, 2016
**/
import java.util.ArrayList;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
public class MyTeam extends PlayerManager {
public ArrayList<OffensivePlayer> myTeamOffObjects = new ArrayList<OffensivePlayer>();
public ArrayList<DefensivePlayer> myTeamDefObjects = new ArrayList<DefensivePlayer>();
MyTeam() {
// Initialize class
}
/*
* Create offense observable list
*/
public ObservableList<String> createOffenseObservableList() {
String[] tempListOfPlayers = new String[myTeamOffObjects.size()];
for (int i = 0; i < myTeamOffObjects.size(); i++) {
tempListOfPlayers[i] = myTeamOffObjects.get(i).playerNum + " - " + myTeamOffObjects.get(i).playerName + " - " + myTeamOffObjects.get(i).playerPosition;
}
ObservableList<String> theOffObsList = FXCollections.observableArrayList (tempListOfPlayers);
return theOffObsList;
}
/*
* Create defense observable list
*/
public ObservableList<String> createDefenseObservableList() {
String[] tempListOfPlayers = new String[myTeamDefObjects.size()];
for (int i = 0; i < myTeamDefObjects.size(); i++) {
tempListOfPlayers[i] = myTeamDefObjects.get(i).playerNum + " - " + myTeamDefObjects.get(i).playerName + " - " + myTeamDefObjects.get(i).playerPosition;
}
ObservableList<String> theDefObsList = FXCollections.observableArrayList (tempListOfPlayers);
return theDefObsList;
}
/*
* Remove offensive player
*/
public void removeOffPlayer(int index) {
myTeamOffObjects.remove(index);
}
/*
* Add offensive player
*/
public void addOffPlayer(OffensivePlayer playerObject) {
myTeamOffObjects.add(playerObject);
}
/*
* Remove defensive player
*/
public void removeDefPlayer(int index) {
myTeamDefObjects.remove(index);
}
/*
* Add defensive player
*/
public void addDefPlayer(DefensivePlayer playerObject) {
myTeamDefObjects.add(playerObject);
}
/*
* Returns a single Offensive player object
*/
public OffensivePlayer getOffPlayerObject(String playerName) {
OffensivePlayer playerObject = null;
for(OffensivePlayer player : myTeamOffObjects) {
if (player.playerName.equals(playerName))
playerObject = player;
}
return playerObject;
}
/*
* Returns a single Defensive player object
*/
public DefensivePlayer getDefPlayerObject(String playerName) {
DefensivePlayer playerObject = null;
for(DefensivePlayer player : myTeamDefObjects) {
if (player.playerName.equals(playerName))
playerObject = player;
}
return playerObject;
}
/*
* Returns the arraylist of myteam offensive players
*/
public ArrayList<OffensivePlayer> getMyTeamOffense() {
return myTeamOffObjects;
}
/*
* Returns the arraylist of myteam defensive players
*/
public ArrayList<DefensivePlayer> getMyTeamDefense() {
return myTeamDefObjects;
}
}