Skip to content
Snippets Groups Projects
Commit 12dedb8a authored by Winnie's avatar Winnie
Browse files

- Added and improved documentation.

parent 8fb48ff4
No related branches found
No related tags found
No related merge requests found
...@@ -2,18 +2,32 @@ package biotree; ...@@ -2,18 +2,32 @@ package biotree;
import java.util.ArrayList; 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 { public class TaxonNode {
//JSON returns long
private final int taxonId; private final int taxonId;
private final TaxonType taxonType; private final TaxonType taxonType;
private final String name; 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 ArrayList<TaxonNode> children = new ArrayList<TaxonNode>();
private int count; private int count;
/**
* TaxonNode constructor
*
* @param taxonId
* @param taxonType
* @param name
*/
public TaxonNode(int taxonId, TaxonType taxonType, String name) { public TaxonNode(int taxonId, TaxonType taxonType, String name) {
this.taxonId = taxonId; this.taxonId = taxonId;
this.taxonType = taxonType; this.taxonType = taxonType;
...@@ -23,43 +37,92 @@ public class TaxonNode { ...@@ -23,43 +37,92 @@ public class TaxonNode {
this.count = 0; this.count = 0;
} }
/**
* Gets the TaxonNode's Id
*
* @return taxonId
*/
public int getTaxonId() { public int getTaxonId() {
return this.taxonId; return this.taxonId;
} }
/**
* Gets the TaxonNode's Type
*
* @return taxonType
*/
public TaxonType getTaxonType() { public TaxonType getTaxonType() {
return this.taxonType; return this.taxonType;
} }
/**
* Gets the TaxonNode's Name
*
* @return Name
*/
public String getName() { public String getName() {
return this.name; return this.name;
} }
public void setParent(TaxonNode parent) { /**
this.parent = parent; * Gets the TaxonNode's Parent
} *
* @return parent
public void addChild(TaxonNode newChild) { */
this.children.add(newChild);
}
public TaxonNode getParent() { public TaxonNode getParent() {
return this.parent; return this.parent;
} }
//Stub Changed /**
* Gets the TaxonNode's Arraylist of Children
*
* @return Arraylist of children
*/
public Iterable<TaxonNode> getChildren() { public Iterable<TaxonNode> getChildren() {
return this.children; return this.children;
} }
/**
* Gets the TaxonNode's Children Count
*
* @return Children Count
*/
public int getCount() { public int getCount() {
return this.count; 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() { public void incCount() {
this.count ++; this.count ++;
} }
/**
* Converts the properties of the taxonNode to String format
*
* @return String of TaxonNode properties
*/
public String toString() { public String toString() {
String s = ""; String s = "";
s += String.format("%-20s%s\n", "Scientific Name:", name); s += String.format("%-20s%s\n", "Scientific Name:", name);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment