diff --git a/src/Board.java b/src/Board.java index 9edfbdc..9a6ac92 100644 --- a/src/Board.java +++ b/src/Board.java @@ -1,5 +1,7 @@ /** - * Die Board-Klasse repräsentiert das Spielfeld. + * Diese Klasse ist das Board von eimem spieler und enthält alle logischen operationen. + * Sprich ist das Backend Board. + * * @author Peer Ole Wachtel, Florian Alexy und Florian Hantzschel */ @@ -8,13 +10,27 @@ import java.util.List; public class Board { + /** + * Alle bisher empfangenen HitResponsen + */ private List hits; - private List ships; - private final int size; /** - * Initialisiert das Board und die zu Setzenden schiffe. - * @param size + * Alle Schiffe des Semesters + */ + private List ships; + + /** + * Die größe des Spielfeldes + */ + private final int size; + + + /** + * Erstellt ein neues Board. + * setzt die übergebene Spielfeldgröße. + * Erstellt die Liste aller Schiffe des Semesters + * @param size Die größe des Spielfeldes * @author Peer Ole Wachtel, Florian Alexy und Florian Hantzschel */ public Board(int size) { @@ -24,6 +40,12 @@ public class Board { this.createShip(size - 13); } + /** + * Nimmt einen punkt entgegen und Gibt einen Hitrespons zurück. + * @param point auf den geschossen wurde + * @return + * @author Peer Ole Wachtel + */ public synchronized HitResponse hit (Point point){ HitResponse response = new HitResponse(HitResponseType.MISS,point); for (int i = 0; i < this.ships.size(); i++) { @@ -95,7 +117,7 @@ public class Board { * to all adjacened hit responses with type HIT using `propagateSunk`. * @param hitResponse the HitResponse to be added * @return true when the hit response was added, otherwise false - * + * */ public synchronized boolean addHits(HitResponse hitResponse) { if (this.getHitResponseOnPoint(hitResponse.getPoint()) == null){ @@ -115,6 +137,7 @@ public class Board { /** * @param point the position to get the hit response from * @return the hit response at the position `point` + * @author Peer Ole Wachtel */ public synchronized HitResponse getHitResponseOnPoint(Point point) { for (int i = 0; i < this.hits.size(); i++){ diff --git a/src/HitResponse.java b/src/HitResponse.java index 2e5f0ca..56560d3 100644 --- a/src/HitResponse.java +++ b/src/HitResponse.java @@ -1,14 +1,33 @@ public class HitResponse { + /** + * Speichert den typ der HitResponse. + */ private HitResponseType type; + /** + * Speicher den Punkt wofür die HitResponse gilt. + */ private Point point; + /** + * Erstellt eine neue HitResponse und setzt den Punkt und typ. + * @param type der HitResponse. + * @param point für den die HitResponse gilt. + * @author Peer Ole Wachtel. + */ public HitResponse(HitResponseType type, Point point) { this.type = type; this.point = point; } + /** + *Erstellt eine neue HitResponse und setzt den Punkt und typ. + * @param typeIndex der HitResponse. + * @param point für den die HitResponse gilt. + * @throws IllegalArgumentException wenn der übergebene int nicht auf ein typ referenziert werden kann. + * @author Peer Ole Wachtel. + */ public HitResponse (int typeIndex, Point point) { if (typeIndex >= 0 && typeIndex < HitResponseType.values().length) { this.type = HitResponseType.values()[typeIndex]; @@ -26,15 +45,30 @@ public class HitResponse { return this.point; } + /** + * Setter für den type + * @param type auf den die HitResponse gesetzt werden soll. + * @author Peer Ole Wachtel + */ public void setType(HitResponseType type) { this.type = type; } + /** + * Gibt den passenden string nach Netzwerkstandard für eine HitResponse zurück. + * @return den passenden string nach Netzwerkstandard für eine HitResponse. + * @author Peer Ole Wachtel. + */ @Override public String toString() { return this.getPoint().toString() + " " + this.type.ordinal(); } + /** + * Getter für den typ der HitResponse. + * @return den typ der HitRespnse. + * @author Peer Ole Wachtel. + */ public HitResponseType getType() { return type; } diff --git a/src/HitResponseType.java b/src/HitResponseType.java index 4b1237c..0b2db42 100644 --- a/src/HitResponseType.java +++ b/src/HitResponseType.java @@ -1,3 +1,7 @@ +/** + * Stellt die verschiedenen möglichkeiten einer HitResponse als typ dar. + * @author Peer Ole Wachtel + */ public enum HitResponseType { MISS, HIT, SUNK, VICTORY } diff --git a/src/LocalPlayer.java b/src/LocalPlayer.java index ffd87c5..70d3cef 100644 --- a/src/LocalPlayer.java +++ b/src/LocalPlayer.java @@ -2,6 +2,11 @@ import java.util.Random; public class LocalPlayer extends Player { + + /** + * erstellt einen LocalPlayer und setzt myCoin random + * @author Peer Ole Wachtel + */ public LocalPlayer(){ super(); Random random = new Random(); diff --git a/src/Point.java b/src/Point.java index 301ec1e..3f37221 100644 --- a/src/Point.java +++ b/src/Point.java @@ -6,6 +6,7 @@ public class Point { * initialises a point using X and Y coordinates starting at 0 * @param x the x coordinate of the point starting at 0 * @param y the y coordinate of the point starting at 0 + * @author Peer Ole Wachtel */ public Point (int x, int y) { this.setX(x);