From 12dedb8ae63ad133b28c99d3af7f0543dcd25fe4 Mon Sep 17 00:00:00 2001 From: Winnie <liang15@mcmaster.ca> Date: Wed, 7 Mar 2018 09:33:27 -0500 Subject: [PATCH] - Added and improved documentation. --- src/biotree/TaxonNode.java | 93 ++++++++++++++++++++++++++++++++------ 1 file changed, 78 insertions(+), 15 deletions(-) diff --git a/src/biotree/TaxonNode.java b/src/biotree/TaxonNode.java index 079e4d7..438711f 100644 --- a/src/biotree/TaxonNode.java +++ b/src/biotree/TaxonNode.java @@ -2,18 +2,32 @@ package biotree; import java.util.ArrayList; -// https://stackoverflow.com/questions/2697182/how-to-use-an-array-list +/** + * This class implements TaxonNode ADT + * The BioTree class uses these nodes to construct its tree. + * An implicit taxonomic hierarchy is constructed via. the parent and children properties. + * + * Used the following source(s): + * https://stackoverflow.com/questions/2697182/how-to-use-an-array-list + */ public class TaxonNode { - //JSON returns long private final int taxonId; private final TaxonType taxonType; private final String name; - private TaxonNode parent; // this can't be final unless parent is recursively returned and constructed in constructor. + private TaxonNode parent; private ArrayList<TaxonNode> children = new ArrayList<TaxonNode>(); private int count; + + /** + * TaxonNode constructor + * + * @param taxonId + * @param taxonType + * @param name + */ public TaxonNode(int taxonId, TaxonType taxonType, String name) { this.taxonId = taxonId; this.taxonType = taxonType; @@ -23,43 +37,92 @@ public class TaxonNode { this.count = 0; } + /** + * Gets the TaxonNode's Id + * + * @return taxonId + */ public int getTaxonId() { return this.taxonId; } - + + /** + * Gets the TaxonNode's Type + * + * @return taxonType + */ public TaxonType getTaxonType() { return this.taxonType; } - + + /** + * Gets the TaxonNode's Name + * + * @return Name + */ public String getName() { return this.name; } - - public void setParent(TaxonNode parent) { - this.parent = parent; - } - - public void addChild(TaxonNode newChild) { - this.children.add(newChild); - } - + + /** + * Gets the TaxonNode's Parent + * + * @return parent + */ public TaxonNode getParent() { return this.parent; } - //Stub Changed + /** + * Gets the TaxonNode's Arraylist of Children + * + * @return Arraylist of children + */ public Iterable<TaxonNode> getChildren() { return this.children; } + + /** + * Gets the TaxonNode's Children Count + * + * @return Children Count + */ public int getCount() { return this.count; } + + /** + * Sets the TaxonNode's Parent + * + * @param parent + */ + public void setParent(TaxonNode parent) { + this.parent = parent; + } + + /** + * Adds a new child to the children list + * + * @param newChild + */ + public void addChild(TaxonNode newChild) { + this.children.add(newChild); + } + + /** + * Increments the children count + */ public void incCount() { this.count ++; } + /** + * Converts the properties of the taxonNode to String format + * + * @return String of TaxonNode properties + */ public String toString() { String s = ""; s += String.format("%-20s%s\n", "Scientific Name:", name); -- GitLab