Skip to content

Commit 274ad2d

Browse files
committed
Fixed display bug in rankReason
- Java 7 and below does not come with a shortcut for joining strings, so it needed to be done manually.
1 parent 8e3f582 commit 274ad2d

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

source/wargame/Benchmark.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,12 +230,29 @@ private String rankReason(HashMap<String, Boolean> criteria) {
230230
if (passes == 0) {
231231
reason = "none";
232232
} else {
233+
// Only in Java
234+
// Would Such
235+
// A Mess Exist
236+
//
233237
String s = " | ";
238+
String[] p = new String[passes];
234239
Iterator it = criteria.entrySet().iterator();
240+
int i = 0;
241+
242+
// collect true entries
235243
while (it.hasNext()) {
236244
Map.Entry pair = (Map.Entry)it.next();
237-
reason += (String)pair.getKey();
238-
if (it.hasNext()) {
245+
if ((Boolean)pair.getValue() == true) {
246+
p[i++] = (String)pair.getKey();
247+
}
248+
}
249+
250+
// merge them into a string
251+
for (int k = 0; k < i; k++) {
252+
reason += p[k];
253+
// do not append the separator to the last
254+
// element listed
255+
if (k < i-1) {
239256
reason += s;
240257
}
241258
}

0 commit comments

Comments
 (0)