From 9d341349432dae54cff71989703bd7c5fab09f2c Mon Sep 17 00:00:00 2001 From: Antonin GODARD Date: Thu, 7 Dec 2017 11:51:14 +0100 Subject: [PATCH 1/5] Added documentation for modified interfaces. --- src/dijkstra/ASetInterface.java | 6 +++++- src/dijkstra/Dijkstra.java | 4 ++-- src/dijkstra/GraphInterface.java | 12 ++++++++---- src/dijkstra/PiInterface.java | 4 ++++ src/dijkstra/Previous.java | 3 --- src/dijkstra/VertexInterface.java | 8 ++++++-- src/maze/Maze.java | 16 ++++++++++++++-- 7 files changed, 39 insertions(+), 14 deletions(-) diff --git a/src/dijkstra/ASetInterface.java b/src/dijkstra/ASetInterface.java index c09024c..3f5c8a4 100644 --- a/src/dijkstra/ASetInterface.java +++ b/src/dijkstra/ASetInterface.java @@ -2,6 +2,9 @@ package dijkstra; import java.util.HashSet; +/** + * This is the ASet class as described in the INF101 course of Telecom Paristech. + */ public interface ASetInterface { /** Add a vertex to the ASet */ @@ -9,7 +12,8 @@ public interface ASetInterface { /** Check if a vertex belongs to ASet */ public boolean contains(VertexInterface vertex) ; - + + /** Returns the HashSet which represents the ASet. */ public HashSet getVertexHashSet(); diff --git a/src/dijkstra/Dijkstra.java b/src/dijkstra/Dijkstra.java index e91af31..1ed1786 100644 --- a/src/dijkstra/Dijkstra.java +++ b/src/dijkstra/Dijkstra.java @@ -26,7 +26,7 @@ public class Dijkstra { if (!a.contains(vertex)) { if (pi.getPi(pivot) + g.getCost(pivot, vertex) < pi.getPi(vertex)) { pi.setPi(pi.getPi(pivot) + g.getCost(pivot, vertex), vertex) ; - previous.setPrevious(pivot, vertex); + previous.setPrevious(pivot, vertex) ; } } } @@ -38,7 +38,7 @@ public class Dijkstra { piMax = pi.getPi(vertex) ; } } - a.add(pivot); + a.add(pivot) ; } return previous ; diff --git a/src/dijkstra/GraphInterface.java b/src/dijkstra/GraphInterface.java index 5c8c8e6..97abce9 100644 --- a/src/dijkstra/GraphInterface.java +++ b/src/dijkstra/GraphInterface.java @@ -1,18 +1,22 @@ package dijkstra; import java.util.ArrayList; +/** + * This is the Graph class as described in the INF101 course of Telecom Paristech. + * + */ public interface GraphInterface { - /** Returns the number of Vertexes **/ + /** Returns the number of Vertexes. **/ public int getVertexNumber() ; - /** Return the cost between two vertexes **/ + /** Return the cost between two vertexes. **/ public int getCost(VertexInterface start, VertexInterface end) ; - /** Returns an list of Vertexes **/ + /** Returns an list of Vertexes. **/ public ArrayList getVertexes() ; - /** Returns the neighbour list for a given box */ + /** Returns the neighbour list for a given box. */ public ArrayList generateNeighbours(VertexInterface vertex) ; } diff --git a/src/dijkstra/PiInterface.java b/src/dijkstra/PiInterface.java index 87fce98..4e74e9f 100644 --- a/src/dijkstra/PiInterface.java +++ b/src/dijkstra/PiInterface.java @@ -1,5 +1,9 @@ package dijkstra; +/** + * This is the Pi class as described in the INF101 course of Telecom Paristech. + * + */ public interface PiInterface { /** Returns the value of pi(v) */ diff --git a/src/dijkstra/Previous.java b/src/dijkstra/Previous.java index b6acaeb..527b8af 100644 --- a/src/dijkstra/Previous.java +++ b/src/dijkstra/Previous.java @@ -2,9 +2,6 @@ package dijkstra; import java.util.ArrayList; import java.util.Hashtable; -import java.util.List; - -import maze.Box; public class Previous implements PreviousInterface { diff --git a/src/dijkstra/VertexInterface.java b/src/dijkstra/VertexInterface.java index e62827c..b0ffe0d 100644 --- a/src/dijkstra/VertexInterface.java +++ b/src/dijkstra/VertexInterface.java @@ -1,10 +1,14 @@ package dijkstra; -import java.util.List; +/** + * This describes a vertex as seen in graphs (see INF101 course). + * + */ public interface VertexInterface { - /** Compare a Vertex to another */ + /** Compare a Vertex to another. */ public boolean compareTo(VertexInterface vertex) ; + /** Returns the Label of the vertex. */ public String getLabel() ; } diff --git a/src/maze/Maze.java b/src/maze/Maze.java index 93ce736..f616912 100644 --- a/src/maze/Maze.java +++ b/src/maze/Maze.java @@ -8,6 +8,15 @@ import java.util.ArrayList; import dijkstra.GraphInterface; import dijkstra.VertexInterface; +/**

Maze class

+ *

+ * This class describes the maze as a matrix of Boxes ({@link maze.Box}). + * + * + * @author Antonin Godard + * @author Sylvain Rager + * + */ public class Maze implements GraphInterface { @@ -81,16 +90,19 @@ public class Maze } + /**Constructs the maze from a text file, according to each single character on each line. + * @param filename + */ + public final void initFromTextFile(String filename) { FileReader fr = null ; BufferedReader br = null ; - try { //Determines the height of the maze and stores it into lineCount + try { fr = new FileReader(filename) ; br = new BufferedReader(fr) ; while (br.readLine() != null) dimensionY++; - //System.out.println("Line count :" + lineCount); } catch (Exception e) { e.printStackTrace(); } finally { From 8a8eac7ac11883f154398d5a097af1151ef007d5 Mon Sep 17 00:00:00 2001 From: Antonin Godard Date: Thu, 7 Dec 2017 14:29:04 +0100 Subject: [PATCH 2/5] Added some documentation for classes and methods of modified files. --- src/maze/Box.java | 12 ++++++++++++ src/maze/Maze.java | 12 ++++++++++-- src/maze/MazeReadingException.java | 7 +++++++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/maze/Box.java b/src/maze/Box.java index 2326e21..9219de9 100644 --- a/src/maze/Box.java +++ b/src/maze/Box.java @@ -4,6 +4,18 @@ import java.util.List; import dijkstra.VertexInterface; +/**

Box class

+ *

+ * + * This class describes a Box and implements {@link dijkstra.VertexInterface}. + *

+ * A Box is represented with its coordinates, its label, and its neighbourList. It also has a reference on the Maze. + * + * @author Antonin Godard + * @author Sylvain Rager + * + */ + public abstract class Box implements VertexInterface { diff --git a/src/maze/Maze.java b/src/maze/Maze.java index f616912..a5a8dde 100644 --- a/src/maze/Maze.java +++ b/src/maze/Maze.java @@ -10,8 +10,7 @@ import dijkstra.VertexInterface; /**

Maze class

*

- * This class describes the maze as a matrix of Boxes ({@link maze.Box}). - * + * This class describes the maze as a matrix of Boxes ({@link maze.Box}). * * @author Antonin Godard * @author Sylvain Rager @@ -30,6 +29,9 @@ public class Maze } + /** + * + */ public int getCost(VertexInterface start, VertexInterface end) { Box startBox = (Box) start ; @@ -51,6 +53,9 @@ public class Maze return dimensionX*dimensionY ; } + /** + * @param ArrayList + */ public ArrayList getVertexes() { ArrayList vertexList = new ArrayList() ; for (int i = 0 ; i < dimensionX ; i++) { @@ -63,6 +68,9 @@ public class Maze return vertexList ; } + /** + * + */ public ArrayList generateNeighbours(VertexInterface vertex) { Box box = (Box)vertex ; diff --git a/src/maze/MazeReadingException.java b/src/maze/MazeReadingException.java index 0bfd24c..4cc5822 100644 --- a/src/maze/MazeReadingException.java +++ b/src/maze/MazeReadingException.java @@ -1,5 +1,12 @@ package maze; +/**

MazeReadingException exception

+ *

+ * This class is used to throw exception when reading and initiating the maze from a text file. + * + * + */ + public class MazeReadingException extends Exception { From ec845a0da2fcb86ce7ab885d8595270644132605 Mon Sep 17 00:00:00 2001 From: Antonin Godard Date: Thu, 7 Dec 2017 14:35:17 +0100 Subject: [PATCH 3/5] Added .gitignore --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5e1d7a3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +*.html +*.css +src/package-list +src/script.js From 8db8b3faad5eca628a6c4b2daa844296004ff572 Mon Sep 17 00:00:00 2001 From: Antonin Godard Date: Sun, 10 Dec 2017 11:57:52 +0100 Subject: [PATCH 4/5] Remove unneeded javadocs in Maze.java --- src/maze/Maze.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/maze/Maze.java b/src/maze/Maze.java index a5a8dde..55bb3c4 100644 --- a/src/maze/Maze.java +++ b/src/maze/Maze.java @@ -53,9 +53,6 @@ public class Maze return dimensionX*dimensionY ; } - /** - * @param ArrayList - */ public ArrayList getVertexes() { ArrayList vertexList = new ArrayList() ; for (int i = 0 ; i < dimensionX ; i++) { @@ -68,9 +65,6 @@ public class Maze return vertexList ; } - /** - * - */ public ArrayList generateNeighbours(VertexInterface vertex) { Box box = (Box)vertex ; From 4d1d3b39a2c55cf0762809e6af749471c5bf4e99 Mon Sep 17 00:00:00 2001 From: "Sylvain Rager (regar42)" Date: Sun, 10 Dec 2017 15:27:57 +0100 Subject: [PATCH 5/5] Add documentation and fix Javadoc warnings * Describe the aim of the interfaces * Explain what are the box inherited from Box * Fix Javadoc warnings by specifying the parameters and returns of the methods in the interfaces --- src/dijkstra/ASetInterface.java | 19 ++++++++++++++++--- src/dijkstra/GraphInterface.java | 28 +++++++++++++++++++++++----- src/dijkstra/PiInterface.java | 18 +++++++++++++++--- src/dijkstra/PreviousInterface.java | 27 ++++++++++++++++++++++++--- src/dijkstra/VertexInterface.java | 11 +++++++++-- src/maze/ABox.java | 3 +++ src/maze/DBox.java | 4 ++++ src/maze/EBox.java | 4 ++++ src/maze/Maze.java | 1 + src/maze/WBox.java | 4 ++++ 10 files changed, 103 insertions(+), 16 deletions(-) diff --git a/src/dijkstra/ASetInterface.java b/src/dijkstra/ASetInterface.java index 3f5c8a4..4bc12d0 100644 --- a/src/dijkstra/ASetInterface.java +++ b/src/dijkstra/ASetInterface.java @@ -4,16 +4,29 @@ import java.util.HashSet; /** * This is the ASet class as described in the INF101 course of Telecom Paristech. + * The ASet contains vertexes for which the shortest path has already been found (vertexes already examined by the dijkstra algorithm). */ public interface ASetInterface { - /** Add a vertex to the ASet */ + /** + * Adds a vertex to the set. + * @param vertex + * The element to be added to the set. + */ public void add(VertexInterface vertex) ; - /** Check if a vertex belongs to ASet */ + /** + * Checks if a vertex belongs to the set. + * @param vertex + * The element we must check if it belongs to the set. + * @return true if the element is in the set, false if not. + */ public boolean contains(VertexInterface vertex) ; - /** Returns the HashSet which represents the ASet. */ + /** + * Returns the HashSet which represents the ASet. + * @return A HashSet containing the same elements as in the set. + */ public HashSet getVertexHashSet(); diff --git a/src/dijkstra/GraphInterface.java b/src/dijkstra/GraphInterface.java index 97abce9..256a211 100644 --- a/src/dijkstra/GraphInterface.java +++ b/src/dijkstra/GraphInterface.java @@ -3,20 +3,38 @@ import java.util.ArrayList; /** * This is the Graph class as described in the INF101 course of Telecom Paristech. - * + * Graph contains the representation of all the vertexes, with the information on which vertex(es) a vertex is linked to and at what cost. */ public interface GraphInterface { - /** Returns the number of Vertexes. **/ + /** + * Gets the number of VertexInterface in the graph. + * @return An integer giving the number of VertexInterface in the graph. + */ public int getVertexNumber() ; - /** Return the cost between two vertexes. **/ + /** + * Gets the cost of the link (if it exists) between two vertexes. + * @param start + * The departure vertex. + * @param end + * The vertex from which we must see the cost of the link to start. + * @return An integer giving the cost of the link between the given VertexInterface. + */ public int getCost(VertexInterface start, VertexInterface end) ; - /** Returns an list of Vertexes. **/ + /** + * Returns all VertexInterface contained in the graph. + * @return An ArrayList of VertexInterface. + */ public ArrayList getVertexes() ; - /** Returns the neighbour list for a given box. */ + /** + * Returns the neighbour list for a given VertexInterface. + * @param vertex + * The VertexInterface from which we will seek for neighbours. + * @return An ArrayList of VertexInterface. + */ public ArrayList generateNeighbours(VertexInterface vertex) ; } diff --git a/src/dijkstra/PiInterface.java b/src/dijkstra/PiInterface.java index 4e74e9f..3c96101 100644 --- a/src/dijkstra/PiInterface.java +++ b/src/dijkstra/PiInterface.java @@ -2,14 +2,26 @@ package dijkstra; /** * This is the Pi class as described in the INF101 course of Telecom Paristech. - * + * It contains the path's cost to reach vertexes (typically, from the root of the graph). */ public interface PiInterface { - /** Returns the value of pi(v) */ + /** + * Gets the cost to reach the given VertexInterface + * @param vertex + * The VertexInterface from which we get the Pi value (cost) to reach it. + * @return An integer giving the Pi value (cost) the reach the VertexInterface. + * + */ public int getPi(VertexInterface vertex) ; - /** Sets the Pi value of an element */ + /** + * Sets the Pi value of an element + * @param i + * The Pi value (cost) to set. + * @param vertex + * The VertexInterface on which the Pi value (cost) is to be set. + */ public void setPi(int i, VertexInterface vertex) ; } diff --git a/src/dijkstra/PreviousInterface.java b/src/dijkstra/PreviousInterface.java index 02c08b9..c06dd6d 100644 --- a/src/dijkstra/PreviousInterface.java +++ b/src/dijkstra/PreviousInterface.java @@ -2,15 +2,36 @@ package dijkstra; import java.util.ArrayList; +/** + * The PreviousInterface contains information about the father (as in the graph's theory) of some VertexInterface. + * The father of a VertexInterface is the VertexInterface used to reach it. + * Typically in Dijkstra, it's the VertexInterface used to reach vertex with the lowest cost. + */ public interface PreviousInterface { - /** Returns the father of an element */ + /** + * Returns the father of a VertexInterface. + * @param vertex + * The VertexInterface from which we get the father (previous VertexInterface). + * @return The direct previous element used to reach vertex. + */ public VertexInterface getPrevious(VertexInterface vertex) ; - /** Sets the father of an element to another element */ + /** + * Sets the father of an element to another element. + * @param father + * The element that will become the father of the other element. + * @param son + * The element that will be assigned a new father. + */ public void setPrevious(VertexInterface father, VertexInterface son) ; - /**Shortest path from root to a vertex */ + /** + * Shortest path from root to a vertex. + * @param vertex + * The vertex to which the shortest path will be computed. + * @return An ArrayList of the VertexInterface used to reach vertex with the lowest cost. + */ public ArrayList getShortestPathTo(VertexInterface vertex) ; } diff --git a/src/dijkstra/VertexInterface.java b/src/dijkstra/VertexInterface.java index b0ffe0d..e047a9a 100644 --- a/src/dijkstra/VertexInterface.java +++ b/src/dijkstra/VertexInterface.java @@ -6,9 +6,16 @@ package dijkstra; */ public interface VertexInterface { - /** Compare a Vertex to another. */ + /** + * Compares a VertexInterface to another. + * @param vertex + * The vertex to which the equality will be tested. + * @return true is the two VertexInterface are the same, false if not. + */ public boolean compareTo(VertexInterface vertex) ; - /** Returns the Label of the vertex. */ + /** + * @return The label of the element. + */ public String getLabel() ; } diff --git a/src/maze/ABox.java b/src/maze/ABox.java index 1b875d0..ef72aa2 100644 --- a/src/maze/ABox.java +++ b/src/maze/ABox.java @@ -1,5 +1,8 @@ package maze; +/** + * ABox is an arrival Box. It's the last Box to be walked through and it's an exit to the Maze. + */ public class ABox extends Box{ public ABox (String label, int x, int y, Maze maze) { diff --git a/src/maze/DBox.java b/src/maze/DBox.java index 6bcdc8e..3b62e7c 100644 --- a/src/maze/DBox.java +++ b/src/maze/DBox.java @@ -1,5 +1,9 @@ package maze; +/** + * A DBox is the Box on which the user is first in the Maze. + */ + public class DBox extends Box{ public DBox (String label, int x, int y, Maze maze) { diff --git a/src/maze/EBox.java b/src/maze/EBox.java index 88c63d5..b2d968b 100644 --- a/src/maze/EBox.java +++ b/src/maze/EBox.java @@ -1,5 +1,9 @@ package maze; +/** + * An EBox is a Box that can be walked through (an empty box). + */ + public class EBox extends Box{ diff --git a/src/maze/Maze.java b/src/maze/Maze.java index 55bb3c4..6d1c32a 100644 --- a/src/maze/Maze.java +++ b/src/maze/Maze.java @@ -94,6 +94,7 @@ public class Maze /**Constructs the maze from a text file, according to each single character on each line. * @param filename + * The path to the file containing the representation of the maze. */ public final void initFromTextFile(String filename) { diff --git a/src/maze/WBox.java b/src/maze/WBox.java index d0adc4b..29a1107 100644 --- a/src/maze/WBox.java +++ b/src/maze/WBox.java @@ -1,5 +1,9 @@ package maze; +/** + * A WBox is a Box that can't be walked through (a wall). + */ + public class WBox extends Box {