AB3: Fix toString()

This commit is contained in:
2022-03-31 22:08:42 +02:00
parent 01b2fb8989
commit 14d3b61c0b

View File

@ -86,13 +86,14 @@ public class BodyForceTreeMap {
return this.size; return this.size;
} }
private String toString(BodyForceTreeMapItem item, String indent) { private String toString(BodyForceTreeMapItem item) {
String s = "";
if (item == null) { if (item == null) {
return ""; return s;
} }
String s = String.format("%s{%s: %s}\n", indent, item.key(), item.value()); s += this.toString(item.right());
s += this.toString(item.left(), indent + "| "); s += String.format("{%s: %s}\n", item.key(), item.value());
s += this.toString(item.right(), indent + "| "); s += this.toString(item.left());
return s; return s;
} }
@ -101,6 +102,6 @@ public class BodyForceTreeMap {
* descending according to the mass of the bodies. * descending according to the mass of the bodies.
*/ */
public String toString() { public String toString() {
return toString(root, ""); return toString(root);
} }
} }