From b30f15e7c5f6c727d4a887934c00cce2d2748eec Mon Sep 17 00:00:00 2001 From: schrom01 Date: Wed, 8 Dec 2021 12:41:42 +0100 Subject: [PATCH] updating JavaDoc in SiedlerBoard --- src/ch/zhaw/catan/SiedlerBoard.java | 52 +++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 14 deletions(-) diff --git a/src/ch/zhaw/catan/SiedlerBoard.java b/src/ch/zhaw/catan/SiedlerBoard.java index 864a217..04f9afe 100644 --- a/src/ch/zhaw/catan/SiedlerBoard.java +++ b/src/ch/zhaw/catan/SiedlerBoard.java @@ -4,14 +4,29 @@ import ch.zhaw.catan.Config.Land; import ch.zhaw.hexboard.HexBoard; import ch.zhaw.hexboard.Label; -import java.awt.*; +import java.awt.Point; import java.util.List; -import java.util.*; +import java.util.HashMap; +import java.util.Map; +import java.util.ArrayList; +import java.util.Collections; +/** + * Subclass of HexBoard + * Saves the fields wich are set and handels Methods with specific Dice Numbers + */ public class SiedlerBoard extends HexBoard { - Map fields = new HashMap<>(); + /** + * HashMap to save all Fields which are set yet. + * Key: Point with coordinates of the field + * Value: Field Object + */ + HashMap fields = new HashMap<>(); + /** + * Method to create the predefined gamefield from Config. + */ public void createFixGamefield(){ Map resourcePlacement = Config.getStandardLandPlacement(); Map dicePlacement = Config.getStandardDiceNumberPlacement(); @@ -30,13 +45,21 @@ public class SiedlerBoard extends HexBoard { } } - + /** + * Method to get the DiceNumber of a specific field. + * @param field Point with coordinates of the specific field + * @return the DiceNumber of the field. + */ private int getDiceNumber(Point field) { Label label = fields.get(field).getLabel(); return Integer.parseInt(label.toString()); } - + /** + * Method to create a SiedlerBoardTextView Object set the LowerFieldLabels with theirs Dicenumber. + * It is used to print the actual board in TextIO. + * @return String of actual board. + */ public String getTextView () { SiedlerBoardTextView view = new SiedlerBoardTextView(this); for (Map.Entry field : fields.entrySet()) { @@ -45,11 +68,6 @@ public class SiedlerBoard extends HexBoard { return view.toString(); } - - //TODO: Add fields, constructors and methods as you see fit. Do NOT change the signature - // of the methods below. - - /** * Returns the fields associated with the specified dice value. * @@ -66,14 +84,20 @@ public class SiedlerBoard extends HexBoard { return fields; } - + /** + * Method to get the Resources which are payed to a specific faction for a specific field. + * + * @param point The Point with the Coordinates of the field, which should pay resources. + * @param faction The faction, which should get paied. + * @return a ArrayList with all resources, which will be paied to the specified faction. + */ public ArrayList getResourcesforFaction(Point point, Config.Faction faction){ List possibleSettlementField = super.getCornersOfField(point); ArrayList resourcesToPlayer = new ArrayList<>(); - for (Structure structure : possibleSettlementField) { - if (structure.getFaction() == faction) { + for (Settlement settlement : possibleSettlementField) { + if (settlement.getFaction() == faction) { resourcesToPlayer.add(fields.get(point).getResource()); - if (structure instanceof City) { + if (settlement instanceof City) { resourcesToPlayer.add(fields.get(point).getResource()); } }