Add code for creating a labyrinth graph
This commit is contained in:
parent
466bd318ab
commit
4f3fb4c0d9
1 changed files with 19 additions and 0 deletions
|
@ -1,10 +1,28 @@
|
|||
package ch.nuth.zhaw.exbox;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.StringReader;
|
||||
|
||||
public class LabyrinthServer implements CommandExecutor {
|
||||
ServerGraphics g = new ServerGraphics();
|
||||
|
||||
public Graph<DijkstraNode, Edge> createGraph(String s) {
|
||||
// TODO implement 8.2
|
||||
Graph<DijkstraNode, Edge> graph = new AdjListGraph<>(DijkstraNode.class, Edge.class);
|
||||
|
||||
try {
|
||||
try (BufferedReader reader = new BufferedReader(new StringReader(s))) {
|
||||
String currentLine;
|
||||
|
||||
while ((currentLine = reader.readLine()) != null) {
|
||||
String[] elements = currentLine.split(" ");
|
||||
graph.addEdge(elements[0], elements[1], 0);
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
}
|
||||
|
||||
return graph;
|
||||
}
|
||||
|
||||
public void drawLabyrinth(Graph<DijkstraNode, Edge> graph) {
|
||||
|
@ -13,6 +31,7 @@ public class LabyrinthServer implements CommandExecutor {
|
|||
|
||||
private boolean search(DijkstraNode current, DijkstraNode ziel) {
|
||||
// TODO implement 8.4
|
||||
return false;
|
||||
}
|
||||
|
||||
// search and draw result
|
||||
|
|
Loading…
Reference in a new issue