From 4d1d3b39a2c55cf0762809e6af749471c5bf4e99 Mon Sep 17 00:00:00 2001 From: "Sylvain Rager (regar42)" Date: Sun, 10 Dec 2017 15:27:57 +0100 Subject: [PATCH] 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 {