diff --git a/out/production/gruppe06-hufflepuff-projekt3-catan/ch/zhaw/catan/SiedlerBoard.class b/out/production/gruppe06-hufflepuff-projekt3-catan/ch/zhaw/catan/SiedlerBoard.class index d79c503..ae45f03 100644 Binary files a/out/production/gruppe06-hufflepuff-projekt3-catan/ch/zhaw/catan/SiedlerBoard.class and b/out/production/gruppe06-hufflepuff-projekt3-catan/ch/zhaw/catan/SiedlerBoard.class differ diff --git a/out/production/gruppe06-hufflepuff-projekt3-catan/ch/zhaw/catan/SiedlerBoardTextView.class b/out/production/gruppe06-hufflepuff-projekt3-catan/ch/zhaw/catan/SiedlerBoardTextView.class index c8c8e58..fd38f02 100644 Binary files a/out/production/gruppe06-hufflepuff-projekt3-catan/ch/zhaw/catan/SiedlerBoardTextView.class and b/out/production/gruppe06-hufflepuff-projekt3-catan/ch/zhaw/catan/SiedlerBoardTextView.class differ diff --git a/src/ch/zhaw/catan/SiedlerBoard.java b/src/ch/zhaw/catan/SiedlerBoard.java index aca0679..06119e9 100644 --- a/src/ch/zhaw/catan/SiedlerBoard.java +++ b/src/ch/zhaw/catan/SiedlerBoard.java @@ -5,10 +5,8 @@ import ch.zhaw.hexboard.HexBoard; import ch.zhaw.hexboard.Label; import java.awt.*; -import java.util.Collections; -import java.util.HashMap; +import java.util.*; import java.util.List; -import java.util.Map; public class SiedlerBoard extends HexBoard { @@ -35,6 +33,21 @@ public class SiedlerBoard extends HexBoard { } + + private int getDiceNumber(Point field) { + Label label = lowerFieldLabel.get(field); + return Integer.parseInt(label.toString()); + } + + + public SiedlerBoardTextView getTextView () { + SiedlerBoardTextView view = new SiedlerBoardTextView(this); + for (Map.Entry e : lowerFieldLabel.entrySet()) { + view.setLowerFieldLabel(e.getKey(), e.getValue()); + } + return view; + } + private void placeFieldWithoutLabel(Land fieldType, Integer[][] fieldCoordinates) { for(Integer[] coordinates : fieldCoordinates) { addField(new Point(coordinates[0], coordinates[1]), fieldType); @@ -53,14 +66,10 @@ public class SiedlerBoard extends HexBoard { } - - - - - //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. * @@ -69,7 +78,13 @@ public class SiedlerBoard extends HexBoard { */ public List getFieldsForDiceValue(int dice) { //TODO: Implement. - return Collections.emptyList(); + ArrayList fields = new ArrayList<>(); + for(Point field : lowerFieldLabel.keySet()){ + if(getDiceNumber(field) == dice){ + fields.add(field); + } + } + return fields; } /** diff --git a/src/ch/zhaw/catan/SiedlerBoardTextView.java b/src/ch/zhaw/catan/SiedlerBoardTextView.java index d8e3206..68836b1 100644 --- a/src/ch/zhaw/catan/SiedlerBoardTextView.java +++ b/src/ch/zhaw/catan/SiedlerBoardTextView.java @@ -2,6 +2,9 @@ package ch.zhaw.catan; import ch.zhaw.catan.Config.Land; import ch.zhaw.hexboard.HexBoardTextView; +import ch.zhaw.hexboard.Label; + +import java.awt.*; public class SiedlerBoardTextView extends HexBoardTextView {