Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
2XB3FinalProject
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Christopher Schankula
2XB3FinalProject
Commits
12dedb8a
Commit
12dedb8a
authored
7 years ago
by
Winnie
Browse files
Options
Downloads
Patches
Plain Diff
- Added and improved documentation.
parent
8fb48ff4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/biotree/TaxonNode.java
+78
-15
78 additions, 15 deletions
src/biotree/TaxonNode.java
with
78 additions
and
15 deletions
src/biotree/TaxonNode.java
+
78
−
15
View file @
12dedb8a
...
...
@@ -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
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment