-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGame.java
222 lines (185 loc) · 4.3 KB
/
Game.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
import java.sql.Date;
import java.sql.Time;
import java.text.SimpleDateFormat;
import javafx.geometry.HPos;
import javafx.geometry.Pos;
import javafx.geometry.VPos;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.GridPane;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
/**
*
* @author Alyza Diaz Rodriguez
*
*/
public class Game {
private String teamName;
private String opponent;
private String away;
private Date day;
private Time time;
private ImageView teamView;
private ImageView oppView;
private GridPane gPane;
private Scene scene;
private ClassLoader cl;
/**
* Initializes a new game day
* @param n - team name
* @param o - opponent team
* @param a - F = team is playing a home game, T = team is away
* @param d - date of the game
* @param t - time of the game
*/
public Game(String n, String o, String a, Date d, Time t) {
teamName = n;
opponent = o;
away = a;
day = d;
time = t;
cl = this.getClass().getClassLoader();
String tn = "logos/"+teamName.toLowerCase()+".png";
teamView = new ImageView(new Image(cl.getResource(tn).toString()));
teamView.setFitWidth(200);
teamView.setFitHeight(200);
String on = "logos/"+opponent.toLowerCase()+".png";
oppView = new ImageView(new Image(cl.getResource(on).toString()));
oppView.setFitWidth(200);
oppView.setFitHeight(200);
gPane = new GridPane();
scene = new Scene(gPane, 900, 900);
}
/**
* Sets the team name to something else
* @param n
*/
public void setTeamName(String n) {
teamName = n;
}
/**
* Returns the team name
* @return
*/
public String getTeamName() {
return teamName;
}
/**
* Sets the opponent's team name
* @param o
*/
public void setOpponent(String o) {
opponent = o;
}
/**
* Returns the opponent's team name
* @return
*/
public String getOpponent() {
return opponent;
}
/**
* Changes the location of a team's game
* @param a
*/
public void setAway(String a) {
away = a;
}
/**
* Returns if the game is an away game or a home game
* @return
*/
public String getAway() {
return away;
}
/**
* Changes the date of a game
* @param d
*/
public void setDay(Date d) {
day = d;
}
/**
* Returns the date of the game
* @return
*/
public Date getDay() {
return day;
}
/**
* Sets the time for the game
* @param t
*/
public void setTime(Time t) {
time = t;
}
/**
* Returns the time for the game
* @return
*/
public Time getTime() {
return time;
}
/**
* Sets up the information page for the next game
*/
@SuppressWarnings("static-access")
public void setup() {
gPane.setHgap(30);
gPane.setVgap(50);
gPane.setAlignment(Pos.CENTER);
Font bankFont = Font.loadFont(cl.getResource("misc/F25_Bank_Printer.otf").toString(), 25);
Font brushFont = Font.loadFont(cl.getResource("misc/brush.otf").toString(), 30);
Text title = new Text("Next "+opponent+" Game:");
title.setFont(bankFont);
Text tn = new Text(teamName);
tn.setFont(brushFont);
Text at = new Text("at");
at.setFont(bankFont);
Text opp = new Text(opponent);
opp.setFont(brushFont);
SimpleDateFormat form = new SimpleDateFormat("MM/dd/yyyy");
Text d = new Text(form.format(day));
d.setFont(bankFont);
/*
* F: A home game; Opponent at Team Name
* T: An away game; Team Name at Opponent
*
*/
gPane.add(title, 1, 0);
gPane.add(at, 1, 2);
gPane.add(d, 1, 4);
if(away.equals("T")) {
gPane.add(oppView, 0, 2);
gPane.add(opp, 0, 3);
gPane.add(teamView, 2, 2);
gPane.add(tn, 2, 3);
}else {
gPane.add(teamView, 0, 2);
gPane.add(tn, 0, 3);
gPane.add(oppView, 2, 2);
gPane.add(opp, 2, 3);
}
for(Node n: gPane.getChildren()) {
gPane.setHalignment(n, HPos.CENTER);
gPane.setValignment(n, VPos.CENTER);
}
}
/**
* Returns the game's scene
* @return
*/
public Scene getScene() {
return scene;
}
/**
* Returns the game's grid pane
* @return
*/
public GridPane getGrid() {
return gPane;
}
}