Skip to content

Commit

Permalink
Merge pull request #102 from jotoh98/bugfix/#52-javadoc-coverage
Browse files Browse the repository at this point in the history
Bugfix/#52 javadoc coverage
  • Loading branch information
1-alex98 authored Dec 21, 2019
2 parents 453e4d8 + 0117ee8 commit b46ee58
Show file tree
Hide file tree
Showing 29 changed files with 142 additions and 30 deletions.
3 changes: 3 additions & 0 deletions src/main/java/com/treasure/hunt/JavaFxApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
import javafx.scene.Scene;
import javafx.stage.Stage;

/**
* @author jotoh
*/
public class JavaFxApplication extends Application {
public static void main(String[] args) {
launch(args);
Expand Down
32 changes: 23 additions & 9 deletions src/main/java/com/treasure/hunt/game/GameEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@
*/
@Requires(hider = Hider.class, searcher = Searcher.class)
public class GameEngine {
/**
* The height of the playing area.
*/
public static final int HEIGHT = 200;
/**
* The width of the playing area.
*/
public static final int WIDTH = 200;

protected final Searcher searcher;
Expand All @@ -47,6 +53,8 @@ public class GameEngine {
protected boolean firstMove = true;

/**
* The constructor.
*
* @param searcher playing the game
* @param hider playing the game
*/
Expand Down Expand Up @@ -88,12 +96,16 @@ protected static boolean located(List<GeometryItem<Point>> geometryItemsList, Po
return false;
}

/**
* Initialize searcher on initial position {@code (0,0)} and treasure positions.
*
* @return a {@link Move}, since the initialization must be displayed.
*/
public Move init() {
return init(JTSUtils.createPoint(0, 0));
}

/**
* initialize searcher and hider.
* initialize searcher and treasure positions.
*
* @param p initial searcher position
Expand Down Expand Up @@ -124,8 +136,6 @@ public Move init(Point p) {
* The searcher begins since we want not force him,
* to take a initial hint, he eventually do not need,
* f.e. if he works randomized!
* <p>
* Updates the searchers position.
*
* @return the {@link Move}, happened in this step.
*/
Expand All @@ -143,7 +153,7 @@ public Move move() {
}

/**
* Lets the {@link GameEngine#hider} make its move.
* Let the {@link GameEngine#hider} give its {@link Hint}.
*/
protected void hiderMove() {
lastHint = hider.move(lastMovement);
Expand All @@ -152,7 +162,7 @@ protected void hiderMove() {
}

/**
* Lets the {@link GameEngine#searcher} make its move.
* Let the {@link GameEngine#searcher} make {@link Movement}.
*/
protected void searcherMove() {
if (finished.get()) {
Expand All @@ -174,6 +184,8 @@ protected void searcherMove() {
}

/**
* Verifies whether the performed {@link Movement} {@code movement} by the {@link Searcher} followed the rules.
*
* @param movement which gets verified
* @param initialSearcherPosition initial searcher position
* @throws IllegalArgumentException when the {@link Movement} is not valid.
Expand All @@ -198,12 +210,11 @@ protected void verifyMovement(Movement movement, Point initialSearcherPosition)

/**
* TODO implement:
* AngleHints must be correct
* AngleHints must be of angle [0, 180] !?
* CircleHints must contain each other !?
* Verifies whether the performed {@link Movement}' by the searcher and {@link Hint}'s from the hider followed the rules.
* Verifies whether the {@link Hint} {@code hint} given by the {@link Hider} followed the rules.
*
* @param hint hint to be verified
* @param hint {@link Hint} to be verified
* @param treasurePosition treasure position
*/
protected void verifyHint(Hint hint, Point treasurePosition) {
Expand All @@ -222,12 +233,15 @@ protected void verifyHint(Hint hint, Point treasurePosition) {
}

/**
* Sets {@link GameEngine#finished} to true.
* Setter for {@link GameEngine#finished}.
*/
protected void finish() {
finished.set(true);
}

/**
* @return {@code true}, if {@link GameEngine#finished} is true. {@code false}, otherwise.
*/
protected boolean isFinished() {
return finished.get();
}
Expand Down
9 changes: 6 additions & 3 deletions src/main/java/com/treasure/hunt/game/GameManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@
*/
@Slf4j
public class GameManager {

/**
* A thread that is invoked by {@link GameManager#beat(ReadOnlyObjectProperty)} and stopped by {@link GameManager#stopBeat()}.
* He executes {@link GameManager#move(int)} in a given interval.
*/
private Thread beatThread;

@Getter
Expand Down Expand Up @@ -220,7 +223,7 @@ public BooleanProperty getGameFinishedProperty() {
}

/**
* @return true if the shown step is the most up to date one
* @return {@code true}, if the shown step is the most up to date one. {@code false}, otherwise.
*/
public boolean latestStepViewed() {
return moves.size() - 1 == viewIndex.get();
Expand All @@ -239,7 +242,7 @@ public BooleanBinding stepBackwardImpossibleBinding() {
}

/**
* @return true if the shown step is the first one
* @return {@code true}, if the shown step is the first one. {@code false}, otherwise.
*/
public boolean isFirstStepShown() {
return stepBackwardImpossibleBinding().getValue();
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/com/treasure/hunt/game/Move.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,24 @@
import java.util.List;

/**
* This contains every essential data, produced in each move.
*
* @author dorianreineccius
*/
@AllArgsConstructor
@Getter
public class Move {
/**
* The {@link Hint} the {@link com.treasure.hunt.strategy.hider.Hider} gave.
*/
private Hint hint;
/**
* The {@link Movement} the {@link com.treasure.hunt.strategy.searcher.Searcher} did.
*/
private Movement movement;
/**
* The current location of the treasure.
*/
private Point treasureLocation;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

/**
* In this modification, the hider may reset the
* treasure location in each move.
* treasure location in each move,
* after the {@link Searcher} did his {@link com.treasure.hunt.strategy.searcher.Movement}.
*
* @author dorianreineccius
*/
Expand All @@ -18,8 +19,7 @@ public HideAndSeekGameEngine(Searcher searcher, Hider hider) {
}

/**
* In this modification, the {@link GameEngine#hider} can reset the treasure position
* and then gives his hint
* Let the {@link GameEngine#hider} reset the treasure position and give his {@link com.treasure.hunt.strategy.hint.Hint}.
*/
protected void moveHider() {
treasurePos = hider.getTreasureLocation(); // Difference between GameEngine and HideAndSeekGameEngine.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* This package contains game logic for the hide and seek modification.
* <p>
* In this mod, the {@link com.treasure.hunt.strategy.hider.Hider} may replace the
* treasure position in each move, after the {@link com.treasure.hunt.strategy.searcher.Searcher} has moved.
*/
package com.treasure.hunt.game.mods.hideandseek;
4 changes: 4 additions & 0 deletions src/main/java/com/treasure/hunt/game/mods/package-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/**
* This package contains game logic for various modifications of the base game.
*/
package com.treasure.hunt.game.mods;
4 changes: 4 additions & 0 deletions src/main/java/com/treasure/hunt/game/package-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/**
* This package contains game logic.
*/
package com.treasure.hunt.game;
28 changes: 26 additions & 2 deletions src/main/java/com/treasure/hunt/geom/Circle.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,25 @@
import org.locationtech.jts.util.GeometricShapeFactory;

/**
* Adding a Geometry based Circle to the jts Geometry suite.
* Adding a {@link Polygon} based Circle to the {@link org.locationtech.jts} suite.
*
* @author hassel
* @author jotoh
* @see org.locationtech.jts.geom.Geometry
*/
public class Circle extends Polygon {
/**
* The radius of the circle.
*/
double radius;

/**
* The constructor
*
* @param coordinate the center point of the circle.
* @param radius the radius of the circle.
* @param numOfPoints the number of points, the circle get after converting to a {@link Polygon}.
* @param geometryFactory the {@link GeometryFactory}.
*/
public Circle(Coordinate coordinate, double radius, int numOfPoints, GeometryFactory geometryFactory) {
super(null, null, geometryFactory);
GeometricShapeFactory geometricShapeFactory = new GeometricShapeFactory(geometryFactory);
Expand All @@ -25,10 +36,23 @@ public Circle(Coordinate coordinate, double radius, int numOfPoints, GeometryFac
this.shell = (LinearRing) circle.getExteriorRing();
}

/**
* The constructor
*
* @param coordinate the center point of the circle.
* @param radius the radius of the circle.
* @param geometryFactory the {@link GeometryFactory}.
*/
public Circle(Coordinate coordinate, double radius, GeometryFactory geometryFactory) {
this(coordinate, radius, 64, geometryFactory);
}

/**
* The constructor for a circle with a radius of 1.
*
* @param coordinate the center point of the circle.
* @param geometryFactory the {@link GeometryFactory}.
*/
public static Circle UnitCircle(Coordinate coordinate, GeometryFactory geometryFactory) {
return new Circle(coordinate, 1.0, geometryFactory);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* actions. Furthermore, it manages the bounding box representing the visual frame of the canvas inside the
* mathematical vector space. This boundary is used for certain rendering purposes.
*
* @author jotoh
* @version 1.0
*/
@AllArgsConstructor
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/com/treasure/hunt/jts/package-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* This package expands the {@link org.locationtech.jts} suite.
*
* @author jotoh
*/
package com.treasure.hunt.jts;
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
/**
* Classifies a jts geometry item with parameters to distinguish between items for visualization/algorithm usages.
*
* @author jotoh, dorianreineccius
* @see GeometryType for further information about how to classifiy a geometry item.
*/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* This is conventions for GeometryItems,
* how to display them.
*
* @author hassel
* @author jotoh
*/
public enum GeometryType {
// hints
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ public Coordinate computeIntersectionOnBoundary(LineSegment line, LineSegment se


/**
* Computes the 2 Intersections between the bounding circle and the current hint, then
* Merges the resulting Polygon and the remaining possible Area
* to the new possible Area
* Computes the 2 intersections between the bounding circle and the current hint,
* then merges the resulting polygon and the remaining possible area
* to the new possible area
*
* @param hint The hint to integrate
* @return TODO
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/treasure/hunt/strategy/hint/Hint.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* A hint a {@link com.treasure.hunt.strategy.hider.Hider} gives to the {@link com.treasure.hunt.strategy.searcher.Searcher},
* in order he may find the treasure, the {@link com.treasure.hunt.strategy.hider.Hider} hides.
*
* @author hassel
* @author jotoh
*/
public abstract class Hint {
protected List<GeometryItem<?>> additionalGeometryItems = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import java.util.List;

/**
* @author dorianreineccius, hassel
* @author dorianreineccius, jotoh
*/
@Getter
@Slf4j
Expand Down
10 changes: 7 additions & 3 deletions src/main/java/com/treasure/hunt/utils/JTSUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@
import org.locationtech.jts.math.Vector2D;

/**
* Contains JTS Utilities.
* A utility class for the work with {@link org.locationtech.jts}.
*
* @author Rank, dorianreineccius, jotoh, axel12
*/
public final class JTSUtils {
/**
* A static final shared {@link GeometryFactory} we use, such that every usage
* uses the same settings of the geometry factory.
*/
public static final GeometryFactory GEOMETRY_FACTORY = new GeometryFactory();

private JTSUtils() {
Expand Down Expand Up @@ -113,7 +117,7 @@ public static Coordinate normalizedCoordinate(Coordinate fixed, Coordinate float
}

/**
* Proof, that the x- or y-coordinates of two vectors have the same sign.
* Proofs, that the x- or y-coordinates of two vectors have the same sign.
*
* @param v0 first vector to check
* @param v1 second vector to check
Expand Down Expand Up @@ -146,7 +150,7 @@ public static Vector2D negateY(Vector2D v) {
}

/**
* Test, if a given coordinate lays inside of the viewing angle given by a {@link GeometryAngle}.
* Tests, whether a given coordinate lays inside of the viewing angle given by a {@link GeometryAngle}.
*
* @param geometryAngle the view {@link GeometryAngle} the method looks upon searching the given point
* @param coordinate the {@link Coordinate}, we want to know, whether it lies in the angle
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/com/treasure/hunt/utils/JsonFileUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;

/**
* @author axel1200
*/
public class JsonFileUtils {
private static final Gson GSON;

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/treasure/hunt/utils/ReflectionUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import java.util.Arrays;

/**
* @author hassel
* @author jotoh
*/
public class ReflectionUtils {
public static Class interfaceGenericsClass(Class baseClass) {
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/com/treasure/hunt/utils/Requires.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* @author axel12
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface Requires {
Expand Down
Loading

0 comments on commit b46ee58

Please sign in to comment.