From bccd4e10938c55f9b30283338120689ea2e1738e Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Mon, 7 Mar 2016 16:56:11 +0100 Subject: Elaborate documentation (fix missing doc and typos) --- src/ch/epfl/xblast/ArgumentChecker.java | 3 +- src/ch/epfl/xblast/PlayerID.java | 1 + src/ch/epfl/xblast/server/Bomb.java | 14 ++++---- src/ch/epfl/xblast/server/Player.java | 57 +++++++++++++++++++++------------ 4 files changed, 47 insertions(+), 28 deletions(-) (limited to 'src/ch/epfl') diff --git a/src/ch/epfl/xblast/ArgumentChecker.java b/src/ch/epfl/xblast/ArgumentChecker.java index 8e7ba76..a567fbb 100644 --- a/src/ch/epfl/xblast/ArgumentChecker.java +++ b/src/ch/epfl/xblast/ArgumentChecker.java @@ -3,11 +3,12 @@ package ch.epfl.xblast; /** * ArgumentChecker. * + * @author Pacien TRAN-GIRARD (261948) * @author Timothée FLOURE (257420) */ public final class ArgumentChecker { /** - * Return the given value if it is non-negative + * Returns the given value if it is non-negative. * * @param value the tested value * @throws IllegalArgumentException if the value is inferior to 0 diff --git a/src/ch/epfl/xblast/PlayerID.java b/src/ch/epfl/xblast/PlayerID.java index 05a280b..bb77405 100644 --- a/src/ch/epfl/xblast/PlayerID.java +++ b/src/ch/epfl/xblast/PlayerID.java @@ -3,6 +3,7 @@ package ch.epfl.xblast; /** * IDs the 4 different players. * + * @author Pacien TRAN-GIRARD (261948) * @author Timothée FLOURE (257420) */ public enum PlayerID { diff --git a/src/ch/epfl/xblast/server/Bomb.java b/src/ch/epfl/xblast/server/Bomb.java index 889dde0..659adb6 100644 --- a/src/ch/epfl/xblast/server/Bomb.java +++ b/src/ch/epfl/xblast/server/Bomb.java @@ -11,6 +11,8 @@ import java.util.List; import java.util.ArrayList; /** + * A Bomb. + * * @author Pacien TRAN-GIRARD (261948) * @author Timothée FLOURE (257420) */ @@ -21,20 +23,20 @@ public final class Bomb { private int range; /** - * Generate one arm of explosion + * Generates one arm of explosion. */ private Sq> explosionArmTowards(Direction dir) { return Sq.constant( Sq.iterate(position, position -> position.neighbor(dir)).limit(range)).limit(Ticks.EXPLOSION_TICKS); } /** - * Instanciates a new Bomb. + * Instantiates a new Bomb. * * @param ownerId id of the owner of the bomb * @param position position of the bomb * @param fuseLengths length of the bomb's fuse * @param range range of the bomb - * @throws IllegalArguementException if range is negative or fuseLenghts is empty + * @throws IllegalArgumentException if range is negative or fuseLenghts is empty * @throws NullPointerException if ownerId, position or fuseLengths is null */ public Bomb(PlayerID ownerId, Cell position, Sq fuseLengths, int range) { @@ -49,13 +51,13 @@ public final class Bomb { } /** - * Instanciates a new Bomb. + * Instantiates a new Bomb. * * @param ownerId id of the owner of the bomb * @param position position of the bomb - * @param fuseLengths length of the bomb's fuse + * @param fuseLength length of the bomb's fuse * @param range range of the bomb - * @throws IllegalArguementException if range or fuseLengths is negative + * @throws IllegalArgumentException if range or fuseLengths is negative * @throws NullPointerException if ownerId, position or fuseLengths is null */ public Bomb(PlayerID ownerId, Cell position, int fuseLength, int range) { diff --git a/src/ch/epfl/xblast/server/Player.java b/src/ch/epfl/xblast/server/Player.java index 59fb962..0548125 100644 --- a/src/ch/epfl/xblast/server/Player.java +++ b/src/ch/epfl/xblast/server/Player.java @@ -10,7 +10,7 @@ import ch.epfl.cs108.Sq; import java.util.Objects; /** - * Player. + * A Player. * * @author Pacien TRAN-GIRARD (261948) * @author Timothée FLOURE (257420) @@ -21,7 +21,7 @@ public final class Player { */ public static final class LifeState { /** - * Enum containing all the possible states. + * Enum containing all the possible life states. */ public enum State { INVULNERABLE, @@ -34,9 +34,9 @@ public final class Player { private final State state; /** - * Instanciates a new LifeSate. + * Instantiates a new LifeSate. * - * @param lives the number of lifes + * @param lives the number of lives * @param state the state * @throws IllegalArgumentException if lives is negative */ @@ -89,7 +89,7 @@ public final class Player { } /** - * Instanciates a new DirectedPos + * Instantiates a new DirectedPos * * @param position the position of the player * @param direction the direction of the player @@ -129,6 +129,9 @@ public final class Player { } } + /** + * The default Direction of a new Player. + */ private static final Direction DEFAULT_DIRECTION = Direction.S; private final PlayerID id; @@ -137,6 +140,12 @@ public final class Player { private final int maxBombs; private final int bombRange; + /** + * Builds a default LifeState sequence with the given number of lives. + * + * @param lives number of lives of the desired sequence + * @return the sequence + */ private static Sq buildDefaultLifeStateSequence(int lives) { LifeState invulnerability = new LifeState( ArgumentChecker.requireNonNegative(lives), @@ -150,6 +159,12 @@ public final class Player { return Sq.repeat(Ticks.PLAYER_INVULNERABLE_TICKS,invulnerability).concat(Sq.constant(vulnerability)); } + /** + * Builds a default DirectedPosition sequence at the given position. + * + * @param pos the position + * @return the sequence + */ private static Sq buildDefaultDirectedPositionSequence(Cell pos) { DirectedPosition dp = new DirectedPosition( SubCell.centralSubCellOf(Objects.requireNonNull(pos)), @@ -160,15 +175,15 @@ public final class Player { } /** - * Instanciates a new Player. + * Instantiates a new Player. * - * @param id - * @param lifeStates - * @param directedPos - * @param maxBombs - * @param bombRange - * @throws IllegalArfuementException - * @throws NullPointerExeption + * @param id the Player's id + * @param lifeStates a sequence of LifeState-s + * @param directedPos a sequence of DirectedPosition-s + * @param maxBombs the maximum number of Bomb-s the Player can carry + * @param bombRange the range of the Bomb-s + * @throws IllegalArgumentException + * @throws NullPointerException */ public Player(PlayerID id, Sq lifeStates, Sq directedPos, int maxBombs, int bombRange) { this.id = Objects.requireNonNull(id); @@ -179,15 +194,15 @@ public final class Player { } /** - * Instanciates a new Player. + * Instantiates a new Player. * - * @param id - * @param lives - * @param position - * @param maxBombs - * @param bombRange + * @param id the Player's id + * @param lives the number of lives of the Player + * @param position the starting position of the Player + * @param maxBombs the maximum number of Bomb-s the Player can carry + * @param bombRange the range of the Bomb-s * @throws IllegalArgumentException - * @throws NullPointerExeption + * @throws NullPointerException */ public Player(PlayerID id, int lives, Cell position, int maxBombs, int bombRange) { this( @@ -244,7 +259,7 @@ public final class Player { } /** - * @return the current number of lifes of the player + * @return the current number of lives of the player */ public int lives() { return lifeStates.head().lives(); -- cgit v1.2.3