1
1
package lap_race ;
2
2
3
- import java .io .FileInputStream ;
3
+ import common .Race ;
4
+
4
5
import java .io .IOException ;
5
6
import java .nio .file .Path ;
6
7
import java .nio .file .Paths ;
7
8
import java .time .Duration ;
8
9
import java .util .*;
9
10
10
- public class Results {
11
+ public class LapRace extends Race {
11
12
12
13
//////////////////////////////////////////// SET UP ////////////////////////////////////////////
13
14
// //
@@ -24,8 +25,6 @@ private record IndividualLegStart(int bib_number, int leg_number, Duration start
24
25
25
26
//////////////////////////////////////////////////////////////////////////////////////////////////
26
27
27
- Properties properties ;
28
-
29
28
Input input ;
30
29
Output output_CSV , output_HTML , output_text , output_PDF ;
31
30
Prizes prizes ;
@@ -42,7 +41,7 @@ private record IndividualLegStart(int bib_number, int leg_number, Duration start
42
41
43
42
Team [] entries ;
44
43
RawResult [] raw_results ;
45
- OverallResult [] overall_results ;
44
+ TeamResult [] overall_results ;
46
45
Map <Category , List <Team >> prize_winners = new HashMap <>();
47
46
48
47
// Records for each leg whether there was a mass start.
@@ -59,15 +58,14 @@ private record IndividualLegStart(int bib_number, int leg_number, Duration start
59
58
60
59
//////////////////////////////////////////////////////////////////////////////////////////////////
61
60
62
- public Results (final String config_file_path ) throws IOException {
61
+ public LapRace (final String config_file_path ) throws IOException {
63
62
64
- this ( readProperties ( config_file_path ) );
63
+ super ( config_file_path );
65
64
}
66
65
67
- public Results (final Properties properties ) throws IOException {
66
+ public LapRace (final Properties properties ) throws IOException {
68
67
69
- this .properties = properties ;
70
- configure ();
68
+ super (properties );
71
69
}
72
70
73
71
public static void main (String [] args ) throws IOException {
@@ -77,22 +75,12 @@ public static void main(String[] args) throws IOException {
77
75
if (args .length < 1 )
78
76
System .out .println ("usage: java Results <config file path>" );
79
77
else {
80
- new Results (args [0 ]).processResults ();
78
+ new LapRace (args [0 ]).processResults ();
81
79
}
82
80
}
83
81
84
82
//////////////////////////////////////////////////////////////////////////////////////////////////
85
83
86
- private static Properties readProperties (final String config_file_path ) throws IOException {
87
-
88
- try (final FileInputStream in = new FileInputStream (config_file_path )) {
89
-
90
- final Properties properties = new Properties ();
91
- properties .load (in );
92
- return properties ;
93
- }
94
- }
95
-
96
84
public void processResults () throws IOException {
97
85
98
86
initialiseResults ();
@@ -110,7 +98,8 @@ public void processResults() throws IOException {
110
98
printCombined ();
111
99
}
112
100
113
- private void configure () throws IOException {
101
+ @ Override
102
+ protected void configure () throws IOException {
114
103
115
104
readProperties ();
116
105
@@ -262,18 +251,18 @@ private String getPropertyWithDefault(final String property_key, final String de
262
251
263
252
private void initialiseResults () {
264
253
265
- overall_results = new OverallResult [entries .length ];
254
+ overall_results = new TeamResult [entries .length ];
266
255
267
256
for (int i = 0 ; i < overall_results .length ; i ++)
268
- overall_results [i ] = new OverallResult (entries [i ], number_of_legs , this );
257
+ overall_results [i ] = new TeamResult (entries [i ], number_of_legs , this );
269
258
}
270
259
271
260
private void fillLegFinishTimes () {
272
261
273
262
for (final RawResult raw_result : raw_results ) {
274
263
275
264
final int team_index = findIndexOfTeamWithBibNumber (raw_result .bib_number );
276
- final OverallResult result = overall_results [team_index ];
265
+ final TeamResult result = overall_results [team_index ];
277
266
final LegResult [] leg_results = result .leg_results ;
278
267
279
268
final int leg_index = findIndexOfNextUnfilledLegResult (leg_results );
@@ -293,7 +282,7 @@ private void fillLegFinishTimes() {
293
282
final int leg_number = Integer .parseInt (swap [1 ]);
294
283
final int leg_index = leg_number - 1 ;
295
284
296
- final OverallResult result = overall_results [findIndexOfTeamWithBibNumber (bib_number )];
285
+ final TeamResult result = overall_results [findIndexOfTeamWithBibNumber (bib_number )];
297
286
298
287
final Duration temp = result .leg_results [leg_index - 1 ].finish_time ;
299
288
result .leg_results [leg_index - 1 ].finish_time = result .leg_results [leg_index ].finish_time ;
@@ -321,7 +310,7 @@ private void fillDNFs() {
321
310
final int leg_number = Integer .parseInt (dnf [1 ]);
322
311
final int leg_index = leg_number - 1 ;
323
312
324
- final OverallResult result = overall_results [findIndexOfTeamWithBibNumber (bib_number )];
313
+ final TeamResult result = overall_results [findIndexOfTeamWithBibNumber (bib_number )];
325
314
result .leg_results [leg_index ].DNF = true ;
326
315
}
327
316
catch (Exception e ) {
@@ -333,7 +322,7 @@ private void fillDNFs() {
333
322
334
323
private void fillLegStartTimes () {
335
324
336
- for (final OverallResult overall_result : overall_results )
325
+ for (final TeamResult overall_result : overall_results )
337
326
for (int leg_index = 0 ; leg_index < number_of_legs ; leg_index ++)
338
327
fillLegStartTime (overall_result .leg_results , leg_index );
339
328
}
0 commit comments