-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTeam.java
More file actions
137 lines (117 loc) · 3.83 KB
/
Copy pathTeam.java
File metadata and controls
137 lines (117 loc) · 3.83 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
/**
* Contains player objects
* Returns three ints: Forward skill level, defense skill level, and goalie skill level.
*/
import java.util.Random;
public class Team {
// Creates a random object
Random rand = new Random(System.currentTimeMillis());
// Attributes of a team
public String teamName;
public int baseForward;
public int forwardInt;
public int baseDefense;
public int defenseInt;
public int baseGoalie;
public int goalieInt;
public Player[] forwards;
public Player[] defensemen;
public Player[] goalies;
// Takes a team name when method is called
Team(String teamName,
int baseForward,
int forwardInt,
int baseDefense,
int defenseInt,
int baseGoalie,
int goalieInt) {
this.teamName = teamName;
this.baseForward = baseForward;
this.forwardInt = forwardInt;
this.baseDefense = baseDefense;
this.defenseInt = defenseInt;
this.baseGoalie = baseGoalie;
this.goalieInt = goalieInt;
this.forwards = createForwards();
this.defensemen = createDefensemen();
this.goalies = createGoalies();
}
// Create all the player objects within a team
// Makes 13 Forwards
public Player[] createForwards() {
Player[] forwards = new Player[1];
// Try implementing a for loop later
forwards[0] = new Player("Forward", 'F', rand.nextInt(100) + 1, rand.nextInt(forwardInt) + baseForward);
return forwards;
}
// Makes 8 Defensemen
public Player[] createDefensemen() {
Player[] defensemen = new Player[1];
// Try implementing a for loop later
defensemen[0] = new Player("Defenseman", 'D', rand.nextInt(100) + 1, rand.nextInt(defenseInt) + baseDefense);
return defensemen;
}
// Makes 4 Goalies
public Player[] createGoalies() {
Player[] goalies = new Player[1];
// Try implementing a for loop later
goalies[0] = new Player("Goalie", 'G', rand.nextInt(100) + 1, rand.nextInt(goalieInt) + baseGoalie);
return goalies;
}
// Puts skill level of players in an array
public int[] forwardSkillArray = {
forwards[0].playerSkill,
// F2.playerSkill,
// F3.playerSkill,
// F4.playerSkill,
// F5.playerSkill,
// F6.playerSkill,
// F7.playerSkill,
// F8.playerSkill,
// F9.playerSkill,
// F10.playerSkill,
// F11.playerSkill,
// F12.playerSkill,
// F13.playerSkill
};
public int[] defenseSkillArray = {
defensemen[0].playerSkill,
// D2.playerSkill,
// D3.playerSkill,
// D4.playerSkill,
// D5.playerSkill,
// D6.playerSkill,
// D7.playerSkill,
// D8.playerSkill,
};
public int[] goalieSkillArray = {
goalies[0].playerSkill,
// G2.playerSkill,
// G3.playerSkill,
// G4.playerSkill
};
public int forwardSkill() {
int sumForward = 0;
for (int i : forwardSkillArray)
sumForward += i;
System.out.println(sumForward);
return sumForward;
}
public int defenseSkill() {
int sumDefense = 0;
for (int i : defenseSkillArray)
sumDefense += i;
return sumDefense;
}
public int goalieSkill() {
int randGoalie = rand.nextInt(4);
int sumGoalie = goalieSkillArray[randGoalie];
return sumGoalie;
}
// prints the skill level for this team
public void printSkill() {
System.out.println(forwardSkill());
System.out.println(defenseSkill());
System.out.println(goalieSkill());
}
}