Refatored Vertex class and changed initialization
This commit is contained in:
@@ -95,6 +95,15 @@ public class Game {
|
||||
int tmp, tmp_i = 0;
|
||||
int alt = 0;
|
||||
|
||||
// Get a verticies list from the field data
|
||||
for(int i = 0; i < size; i++){
|
||||
for(int j = 0; i < size; i++){
|
||||
if(field[i][j] == 0){
|
||||
vertices.add(new Vertex(Integer.MAX_VALUE, new Point(i, j)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = 0; i < size*size; i++){
|
||||
vertices.add(new Vertex(Integer.MAX_VALUE, new Point(i%7,i%7))); // Initialize all vertices
|
||||
}
|
||||
|
||||
@@ -5,18 +5,24 @@ import java.awt.Point;
|
||||
public class Vertex {
|
||||
|
||||
private int dist;
|
||||
private Point prev;
|
||||
private Point pos;
|
||||
private Vertex prev;
|
||||
|
||||
public Vertex(int dist, Point prev) {
|
||||
public Vertex(int dist, Point pos) {
|
||||
this.dist = dist;
|
||||
this.prev = prev;
|
||||
this.pos = pos;
|
||||
this.prev = new Vertex(0, new Point(0,0));
|
||||
}
|
||||
|
||||
public void setDist(int dist){
|
||||
this.dist = dist;
|
||||
}
|
||||
|
||||
public void setPrev(Point prev){
|
||||
public void setPos(Point pos){
|
||||
this.pos = pos;
|
||||
}
|
||||
|
||||
public void setPrev(Vertex prev){
|
||||
this.prev = prev;
|
||||
}
|
||||
|
||||
@@ -24,7 +30,11 @@ public class Vertex {
|
||||
return this.dist;
|
||||
}
|
||||
|
||||
public Point getPrev(){
|
||||
public Point getPos(){
|
||||
return this.pos;
|
||||
}
|
||||
|
||||
public Vertex getPrev(){
|
||||
return this.prev;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user