Minor doc and method name changes.

Respective tests updated.
This commit is contained in:
Harrison Deng 2020-04-24 15:08:59 -05:00
parent 8acc653b5b
commit ffc01f0ddf
2 changed files with 10 additions and 11 deletions

View File

@ -43,7 +43,7 @@ public class DepthFirstSearch {
startNode = new DFSNode(null, x, y, endNode); startNode = new DFSNode(null, x, y, endNode);
} }
public void setDirectionPosition(int x, int y) { public void setEndPosition(int x, int y) {
endNode = new DFSNode(null, x, y, endNode); endNode = new DFSNode(null, x, y, endNode);
} }
@ -72,12 +72,11 @@ public class DepthFirstSearch {
} }
/** /**
* Finds the end node. If an end node is set, it will try going in that * Finds a coordinate determined by a target validator. If an end node is set,
* direction first. Will not set end node if one wasn't found, therefore, * it will try going in that direction first.
* previous end node data is kept.
* *
* @param targetValidator * @param targetValidator
* @return * @return If it succeeded in finding an end node.
*/ */
public boolean findTarget(CoordinateTargetValidatable targetValidator) { public boolean findTarget(CoordinateTargetValidatable targetValidator) {
if (coordValidatable == null) if (coordValidatable == null)

View File

@ -99,7 +99,7 @@ public class DepthFirstSearchTest {
{ {
dfs.setValidatable(new Validator(mapA)); dfs.setValidatable(new Validator(mapA));
dfs.setStartPosition(1, 2); dfs.setStartPosition(1, 2);
dfs.setDirectionPosition(1, 0); dfs.setEndPosition(1, 0);
assertTrue(dfs.buildPathToEndNode()); assertTrue(dfs.buildPathToEndNode());
} }
@ -108,7 +108,7 @@ public class DepthFirstSearchTest {
{ {
dfs.setValidatable(new Validator(mapB)); dfs.setValidatable(new Validator(mapB));
dfs.setStartPosition(3, 0); dfs.setStartPosition(3, 0);
dfs.setDirectionPosition(3, 2); dfs.setEndPosition(3, 2);
assertTrue(dfs.buildPathToEndNode()); assertTrue(dfs.buildPathToEndNode());
} }
@ -117,7 +117,7 @@ public class DepthFirstSearchTest {
{ {
dfs.setValidatable(new Validator(mapD)); dfs.setValidatable(new Validator(mapD));
dfs.setStartPosition(0, 0); dfs.setStartPosition(0, 0);
dfs.setDirectionPosition(0, 3); dfs.setEndPosition(0, 3);
assertTrue(dfs.buildPathToEndNode()); assertTrue(dfs.buildPathToEndNode());
} }
@ -126,7 +126,7 @@ public class DepthFirstSearchTest {
{ {
dfs.setValidatable(new Validator(mapC)); dfs.setValidatable(new Validator(mapC));
dfs.setStartPosition(3, 0); dfs.setStartPosition(3, 0);
dfs.setDirectionPosition(3, 2); dfs.setEndPosition(3, 2);
assertFalse(dfs.buildPathToEndNode()); assertFalse(dfs.buildPathToEndNode());
} }
@ -135,7 +135,7 @@ public class DepthFirstSearchTest {
{ {
dfs.setValidatable(new Validator(mapE)); dfs.setValidatable(new Validator(mapE));
dfs.setStartPosition(3, 0); dfs.setStartPosition(3, 0);
dfs.setDirectionPosition(3, 2); dfs.setEndPosition(3, 2);
assertFalse(dfs.buildPathToEndNode()); assertFalse(dfs.buildPathToEndNode());
} }
@ -217,7 +217,7 @@ public class DepthFirstSearchTest {
Validator validator = new Validator(mapH); Validator validator = new Validator(mapH);
dfs.setValidatable(validator); dfs.setValidatable(validator);
dfs.setStartPosition(3, 0); dfs.setStartPosition(3, 0);
dfs.setDirectionPosition(42, 84); dfs.setEndPosition(42, 84);
assertTrue(dfs.findTarget(validator)); assertTrue(dfs.findTarget(validator));
assertEquals(95, dfs.getFoundNode().getX()); assertEquals(95, dfs.getFoundNode().getX());