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
cd0cf48c
Commit
cd0cf48c
authored
7 years ago
by
Christopher Schankula
Browse files
Options
Downloads
Patches
Plain Diff
add first minimal working BioTree and a few tests for it
parent
f31ab094
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.classpath
+1
-0
1 addition, 0 deletions
.classpath
src/biotree/BioTree.java
+120
-0
120 additions, 0 deletions
src/biotree/BioTree.java
src/biotree/TestBioTree.java
+31
-0
31 additions, 0 deletions
src/biotree/TestBioTree.java
with
152 additions
and
0 deletions
.classpath
+
1
−
0
View file @
cd0cf48c
...
...
@@ -2,5 +2,6 @@
<classpath>
<classpathentry
kind=
"src"
path=
"src"
/>
<classpathentry
kind=
"con"
path=
"org.eclipse.jdt.launching.JRE_CONTAINER"
/>
<classpathentry
kind=
"con"
path=
"org.eclipse.jdt.junit.JUNIT_CONTAINER/4"
/>
<classpathentry
kind=
"output"
path=
"bin"
/>
</classpath>
This diff is collapsed.
Click to expand it.
src/biotree/BioTree.java
0 → 100644
+
120
−
0
View file @
cd0cf48c
package
biotree
;
public
class
BioTree
{
private
static
Species
[]
species
;
private
static
int
n
;
/**
* Initialize species abstract object
*/
public
static
void
init
()
{
species
=
new
Species
[
500
];
n
=
0
;
}
/**
* TODO: Implement
*
* @param fn
* Filename to read from
*/
public
static
void
init
(
String
fn
)
{
}
/**
* TODO: Implement
*
* @param fn
* Filename to write to
*/
public
static
void
write
(
String
fn
)
{
}
/**
* Add a new species to the module
*
* @param s
* New Species to add.
* @return speciesid of new species entry
*/
public
static
int
addSpecies
(
Species
s
)
{
species
[
n
++]
=
s
;
return
n
;
}
/**
* Update an existing species object.
*
* @param i
* The index of the species to update.
* @param s
* The new Species object to overwrite the old one with.
*/
public
static
void
updateSpecies
(
int
i
,
Species
s
)
{
species
[
i
]
=
s
;
}
/**
* Get the species at a given index (speciesid).
*
* @param i
* The speciesid (index) of the species.
* @return The Species object.
*/
public
static
Species
getSpecies
(
int
i
)
{
return
species
[
i
];
}
/**
* Search for a species by name.
*
* @param s
* The name of the species.
* @return The speciesid of the species or -1 if it is not found.
*/
public
static
int
findSpecies
(
String
s
)
{
for
(
int
i
=
0
;
i
<
n
;
i
++)
if
(
species
[
i
].
getSpecies
()
==
s
)
return
i
;
return
-
1
;
}
/**
* TODO: Implement
*
* @param s
* The name of the genus.
* @return Array of speciesid belonging to the genus.
*/
public
static
int
[]
findGenus
(
String
s
)
{
int
[]
dummy
=
{
1
,
2
,
3
};
return
dummy
;
}
/**
* TODO: Implement
*
* @param s
* The name of the family.
* @return Array of speciesid belonging to the family.
*/
public
static
int
[]
findFamily
(
String
s
)
{
int
[]
dummy
=
{
1
,
2
,
3
};
return
dummy
;
}
/**
* TODO: Implement
*
* @param s
* The name of the order.
* @return Array of speciesid belonging to the order.
*/
public
static
int
[]
findOrder
(
String
s
)
{
int
[]
dummy
=
{
1
,
2
,
3
};
return
dummy
;
}
}
This diff is collapsed.
Click to expand it.
src/biotree/TestBioTree.java
0 → 100644
+
31
−
0
View file @
cd0cf48c
package
biotree
;
import
static
org
.
junit
.
Assert
.*;
import
org.junit.Before
;
import
org.junit.Test
;
public
class
TestBioTree
{
@Before
public
void
setUp
()
throws
Exception
{
BioTree
.
init
();
Species
s0
=
new
Species
(
"Actinopterygii"
,
"Perciformes"
,
"Moronidae"
,
"Morone"
,
"Morone chrysops"
);
Species
s1
=
new
Species
(
"Actinopterygii"
,
"Perciformes"
,
"Percidae"
,
"Perca"
,
"Perca flavescens"
);
BioTree
.
addSpecies
(
s0
);
BioTree
.
addSpecies
(
s1
);
}
@Test
public
void
testFindSpecies
()
{
assert
BioTree
.
findSpecies
(
"Morone chrysops"
)
==
0
;
assert
BioTree
.
findSpecies
(
"Perca flavescens"
)
==
1
;
}
@Test
public
void
testGetSpecies
()
{
assert
BioTree
.
getSpecies
(
0
).
getSpecies
()
==
"Morone chrysops"
;
assert
BioTree
.
getSpecies
(
1
).
getSpecies
()
==
"Perca flavescens"
;
}
}
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