Avancement sur le tp. Implémentation (pas finie) des interfaces pour le
maze et Box.
This commit is contained in:
1 parent
0f7ef69441
commit
f7646c48f6
8 files changed
+75
-16
No files matched your search
@@ -1,9 +1,9 @@
|
|||||||
|
|
||||||
public class ABox extends Box{
|
public class ABox extends Box{
|
||||||
|
|
||||||
public ABox (int x, int y) {
|
public ABox (String label, int x, int y, Maze maze) {
|
||||||
|
|
||||||
super(x,y) ;
|
super(label,x,y,maze) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,14 +1,24 @@
|
|||||||
|
|
||||||
public abstract class Box {
|
public abstract class Box
|
||||||
|
implements VertexInterface {
|
||||||
|
|
||||||
private int x ;
|
private int x ;
|
||||||
private int y ;
|
private int y ;
|
||||||
|
private String label ;
|
||||||
|
private Maze maze ;
|
||||||
|
|
||||||
public Box (int x, int y) {
|
public Box (String label, int x, int y, Maze maze) {
|
||||||
|
this.label = label ;
|
||||||
this.x = x ;
|
this.x = x ;
|
||||||
this.y = y ;
|
this.y = y ;
|
||||||
|
this.maze = maze ;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean compareTo(VertexInterface vertex) {
|
||||||
|
if (this.getLabel() == vertex.getLabel()) {
|
||||||
|
return true ;
|
||||||
|
}
|
||||||
|
return false ;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getX() {
|
public int getX() {
|
||||||
@@ -26,5 +36,23 @@ public abstract class Box {
|
|||||||
public void setY(int y) {
|
public void setY(int y) {
|
||||||
this.y = y;
|
this.y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getLabel() {
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLabel(String label) {
|
||||||
|
this.label = label;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Maze getMaze() {
|
||||||
|
return maze;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMaze(Maze maze) {
|
||||||
|
this.maze = maze;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
|
|
||||||
public class DBox extends Box{
|
public class DBox extends Box{
|
||||||
|
|
||||||
public DBox (int x, int y) {
|
public DBox (String label, int x, int y, Maze maze) {
|
||||||
|
|
||||||
super(x,y) ;
|
super(label,x,y,maze) ;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
|
|
||||||
public class EBox extends Box{
|
public class EBox extends Box{
|
||||||
|
|
||||||
public EBox (int x, int y) {
|
public EBox (String label, int x, int y, Maze maze) {
|
||||||
|
|
||||||
super(x,y) ;
|
super(label,x,y,maze) ;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public interface GraphInterface {
|
||||||
|
|
||||||
|
/** Returns the number of Vertexes */
|
||||||
|
public int getVertexNumber() ;
|
||||||
|
|
||||||
|
/** Return the cost between two vertexes */
|
||||||
|
public int getCost(VertexInterface start, VertexInterface end) ;
|
||||||
|
|
||||||
|
/** Returns an list of Vertexes */
|
||||||
|
public ArrayList<VertexInterface> getVertexes() ;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,15 +1,22 @@
|
|||||||
|
|
||||||
public class Maze {
|
public class Maze
|
||||||
|
implements GraphInterface{
|
||||||
|
|
||||||
int dimensionX ;
|
int dimensionX ;
|
||||||
int dimensionY ;
|
int dimensionY ;
|
||||||
int[][] maze ;
|
int[][] maze ;
|
||||||
|
int[][] adjMatrix ;
|
||||||
|
|
||||||
public Maze(int x, int y) {
|
public Maze(int dimensionX, int dimensionY, int[][] adjmatrix) {
|
||||||
|
|
||||||
this.dimensionX = x ;
|
this.dimensionX = dimensionX ;
|
||||||
this.dimensionY = y ;
|
this.dimensionY = dimensionY ;
|
||||||
this.maze = new int[dimensionX][dimensionY] ;
|
this.maze = new int[dimensionX][dimensionY] ;
|
||||||
|
this.adjMatrix = adjMatrix ;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCost(VertexInterface start, VertexInterface end) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,4 +46,5 @@ public class Maze {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
|
||||||
|
public interface VertexInterface {
|
||||||
|
|
||||||
|
/** Compare a Vertex to another */
|
||||||
|
public boolean compareTo(VertexInterface vertex) ;
|
||||||
|
|
||||||
|
public String getLabel() ;
|
||||||
|
|
||||||
|
}
|
||||||
Reference in new issue
Block a user