Add UI to the project #29

Manually merged
regar42 merged 45 commits from mvc into master 2018-01-03 11:03:09 +00:00
3 changed files with 12 additions and 5 deletions
Showing only changes of commit c7134e9e91 - Show all commits

No files matched your search

+1 -1
View File
@@ -22,7 +22,7 @@ public class Dijkstra {
int n = g.getVertexNumber(); int n = g.getVertexNumber();
for (int j = 0; j < n; j++) { for (int j = 0; j < n; j++) {
for (VertexInterface vertex: g.generateNeighbours(pivot)) { for (VertexInterface vertex: pivot.generateNeighbours()) {
if (!a.contains(vertex)) { if (!a.contains(vertex)) {
if (pi.getPi(pivot) + g.getCost(pivot, vertex) < pi.getPi(vertex)) { if (pi.getPi(pivot) + g.getCost(pivot, vertex) < pi.getPi(vertex)) {
pi.setPi(pi.getPi(pivot) + g.getCost(pivot, vertex), vertex) ; pi.setPi(pi.getPi(pivot) + g.getCost(pivot, vertex), vertex) ;
+7
View File
@@ -1,5 +1,7 @@
package dijkstra; package dijkstra;
import java.util.ArrayList;
/** /**
* This describes a vertex as seen in graphs (see INF101 course). * This describes a vertex as seen in graphs (see INF101 course).
* *
@@ -11,4 +13,9 @@ public interface VertexInterface {
*/ */
public String getLabel() ; public String getLabel() ;
/**
* Updates the attribute of the element.
* @return The neighbourList of the element.
*/
public ArrayList<VertexInterface> generateNeighbours();
} }
+4 -4
View File
@@ -22,7 +22,7 @@ public abstract class Box
private int y ; private int y ;
private String label = null ; private String label = null ;
private Maze maze ; private Maze maze ;
private ArrayList<Box> neighbourList = new ArrayList<Box>() ; private ArrayList<VertexInterface> neighbourList;
public Box (String label, int y , int x, Maze maze) { //y first because of graphical maze representation public Box (String label, int y , int x, Maze maze) { //y first because of graphical maze representation
@@ -33,9 +33,9 @@ public abstract class Box
} }
public ArrayList<VertexInterface> generateNeighbors() { public ArrayList<VertexInterface> generateNeighbours() {
this.neighbourList = maze.generateNeighbours(this);
return maze.generateNeighbours(this) ; return maze.generateNeighbours(this) ;
} }
public boolean isWalkable() { public boolean isWalkable() {
@@ -50,7 +50,7 @@ public abstract class Box
return false ; return false ;
} }
public ArrayList<Box> getNeighbourList() { public ArrayList<VertexInterface> getNeighbourList() {
return neighbourList; return neighbourList;
} }