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