Commit 8fb98f52 authored by Ari Trachtenberg's avatar Ari Trachtenberg
Browse files

* added setters and getters

* moved main out of the package
parent 4734045c
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -12,6 +12,7 @@ class Main {
        BST<String> strTest = new BST<>(strElements);

        System.out.println("Your int BST is:\n"+intTest);
        System.out.println("... right subtree:\n"+intTest.getRight());
        System.out.println("Your string BST is:\n"+strTest);
        System.out.println("One rotation: "+new BstRotation(3, BstRotation.RotationType.ZAG));

+10 −3
Original line number Diff line number Diff line
@@ -49,8 +49,15 @@ public class BST<keyType extends Comparable<keyType> > {
    // METHODS

    // ... getters
    final Integer getNodeId() { return nodeId; }
    final keyType getKey() { return key; }
    public final Integer getNodeId() { return nodeId; }
    public final keyType getKey() { return key; }
    public final BST<keyType> getLeft() { return left; }
    public final BST<keyType> getRight() { return right; }

    // ... setters
    public final void setNodeID(Integer newId) { nodeId=newId; }
    public final void setLeft(BST<keyType> newLeft) { left=newLeft; }
    public final void setRight(BST<keyType> newRight) { left=newRight; }

    /**
     * Compute how to transform this BST into the BST {@code otherTree} using rotations.