From ad1227ac983207458257313505888e3d5b59b2e6 Mon Sep 17 00:00:00 2001 From: schrom01 Date: Wed, 24 Nov 2021 17:03:55 +0100 Subject: [PATCH] completed method getFieldsForDiceValue in SiedlerBoard --- .../ch/zhaw/catan/SiedlerBoard.class | Bin 1000 -> 5398 bytes .../ch/zhaw/catan/SiedlerBoardTextView.class | Bin 681 -> 681 bytes src/ch/zhaw/catan/SiedlerBoard.java | 33 +++++++++++++----- src/ch/zhaw/catan/SiedlerBoardTextView.java | 3 ++ 4 files changed, 27 insertions(+), 9 deletions(-) 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 d79c503c161dd5f21baa4c38c86a0701231694be..ae45f03e38f43bebf7762b40714443a82423af0a 100644 GIT binary patch literal 5398 zcmb7I`F9i775+w=(b)3XmSt>^fsnWcyyAp7EH;}FHmH#ev5Xx-myGSf7RZu28e=YYG&G?ht-B;`k|qX2f$mGXx97Ayr$6?eNI50+zGX&|?F001@VvQm-@V`c z?)Toj(Od6ax(Z-7{uYD}ejTa-4FLs_(TVm)C(N1l32SyFYuaP&hpgHCY@i^pE0sw( zdldK^n}&3hD5yGVo;KU3om9I0keQq4GpB;k;V(rQ3?1bLDp0AQ&W$;0I%cLlk+R0p zmMw!;rn57a-J7z~V{voDN-L<0=c7`@E*(`0Rvj1Cw3!)ik7XQd+_LFOwTq$99z+;5 z25PZdfqvRdPg{piD5!0WHLVb%6cNn3L(xiigRqGP#sgI)$l2G><=*E6Z?qm~=oyv@pCK?Ol2rD%pi~|OG&`Z8k zrk%4$EedK1QApROn2tjV>fNNvK zVFF-f9D6RoXsB|*^3_77t};A?0UZeggE(5m9-mN>axB|)vNn^hER@fUNjn7?#=|<2 z29Dvlf^eRG*M<5wVdna&3chHMu^I0*@IJg>ftumwViLV(n53V4JX(egJ*<>6Jc3aJ zV=O>`+WVk2r-K$(1@|>)oc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=Tg;MMD9y+B@iN7%AiS^O z2Q*8;5AmwZa*4cEiq(4=2a~i-$KovABH{`baYR91>mr5}I_z$u!Fv>f@JN44+agBT z(4ql-nG&o8oSeV;kCs;{lFCul(rW-{MJauKw_po>&9>tJeRs1>o*`@@T(9AEj6~E={TSR+{WGqI%!|(b0Kj4pa4b!X$ S{)E5mi_otXJMh;)>Hh$IBp)OI delta 389 zcma)%O-jR16otQ6+oX9-wQ8(M{f+gHPBLu~u?uh@29SHrl0vYc8ygWizX2m~pvb zCf1obcRJcR?e_+8ayz^<6X)8i9bd(FaTMPt(aBAJkQ^wEjITq}(;vlcMPSA%5YDc` zlhHHXiajEvN7aV1`Ay`Y|DC{Pnk&!CwXb*BLqSd>kuEJ-RYw`EJA z#aHYn@qE|My7lRO^jnrFb(W>(XYoL$1}p!-HS@R}ZI!h@+PeI0%H3cy { @@ -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 {