From 9908656813e450d0e14309007a74713dd770fe62 Mon Sep 17 00:00:00 2001 From: peet Date: Tue, 18 Jun 2024 13:17:01 +0000 Subject: [PATCH] finished uebung10 --- bin/uebung10/logo/HanselGretelTest.class | Bin 0 -> 1271 bytes bin/uebung10/logo/HanselGretelVisitor$1.class | Bin 0 -> 1024 bytes .../logo/HanselGretelVisitor$DownState.class | Bin 795 -> 860 bytes .../logo/HanselGretelVisitor$LongUpSate.class | Bin 798 -> 0 bytes .../HanselGretelVisitor$ShortUpState.class | Bin 804 -> 804 bytes .../logo/HanselGretelVisitor$State.class | Bin 676 -> 676 bytes bin/uebung10/logo/HanselGretelVisitor.class | Bin 3255 -> 3705 bytes src/uebung10/logo/HanselGretelTest.java | 30 +++++++++++++++ src/uebung10/logo/HanselGretelVisitor.java | 35 +++++++++++++----- 9 files changed, 56 insertions(+), 9 deletions(-) create mode 100644 bin/uebung10/logo/HanselGretelTest.class create mode 100644 bin/uebung10/logo/HanselGretelVisitor$1.class delete mode 100644 bin/uebung10/logo/HanselGretelVisitor$LongUpSate.class create mode 100644 src/uebung10/logo/HanselGretelTest.java diff --git a/bin/uebung10/logo/HanselGretelTest.class b/bin/uebung10/logo/HanselGretelTest.class new file mode 100644 index 0000000000000000000000000000000000000000..36adb1b1ad52534a865feeaca6bc61e2589fd126 GIT binary patch literal 1271 zcmZWnYflqF6g@+s3u~2U5g*Y-qZWMBXMBLjqkzUn3B@Lr#AI8>y11Ri?X1Scf8eh% z#x$`}zxxM_@q_=wcxH>x*8Q+EckaFCo^$X0{^#>o01H^P&?9gnlI2KMuUyXhK{d$U zcU4{btD)4=-;i}}p;usN+kNe3eOFbpkIUP#q6HGmYXt$36F9gOsJeEQF1mgslXri; z`~CCBm!?4P+WO;Ffw6pNg@Uf>8G)pZLhVa|@h<;H{LYB}*^2KePtUPhW~xZQrC>{1 z7-3Eqq^EF7cc&gj)3IsbrN z<7eY2PMQpdj54{YqJ>lcRiy}(oPYK&V-hEA4C95(fkZ z^PZBAqFPyo8*bTjY9t?2T)*gsp0VRc8wpI1hkoJJ1)MI_?qRa2eRZj$9f2e3k~_T7XBXx3Ae1u}u5*%|J!uUpIo}dV(${dy2)xZsW^y@p z#>kmTA%%kiDYH!*q^_z)%TPYpt6@B>aF3ez7i~EVgRmb90uP_4P}T$gwcK(lL2bwL zW1`MZ7?64Gj$;oj`flar3W?UWQ*n(Jr!1YlEFCzmqu=gG+r}K03`s6-I+NcoSJ0uS zsxxNI>_QNQ6}jRWp6Tu$UNSkDq_PBsCkWMtBrS_p5Bh0ydhwmIdG_+{5C$1BMC&~U z_y;zd7%mMZzhJbKXd+!|;BcYT+r-h*7>+k^qEPB?C58gwuAb8OW(@_Pj6_!P`hE z5e)sk zHKvl})sNg^5e_yj+-BHX*e8xVxT{;6L`o}h=CYlo{*I0Ncxd4P!}|Zo*?*2(SZ81p z`i@A&M1Bbwa&>oTla?ySF18u$Q6#)cH=@e5#2UvI>J08&%IiiYoq&$M)!^9IxAO69 zDC|?2L}T&B*XlQ~xqJB0`|MHEkHc{wV?UgJ5b9i#Qr-_k5p@GEjs^8OpH11yiHKEC z#tM(=nR7JKtX$S_O_n}cSRsFrtYi5QV?F(WZ&PR%_~CwYL7Gts5zVNLK-uf+*E}K%qiGY2(6`&k(ZoDGJqv z3zsf@24BRDI0=GW=ALur%p92K!dIdE`SbP;gmi3-u%Cp@Nw+3*E6^42JT}3#j$OR>3)m%H2Sx}`btg?nE zTc@VzC_C1ftW(P3vYN8-LgPQQklXz{&_fQh*}p`K9aV;1_7oTMB%eUh(py?HhIa1z EzYmEh761SM delta 297 zcmZuqO%B0e6rA_9sYrwpimIPl2oEztU(ikYs+ n>GMxT?K?Pso4?PaKS=|1K2mVeAeXoaJhaFLxos+RwC_CuRrVPQ diff --git a/bin/uebung10/logo/HanselGretelVisitor$LongUpSate.class b/bin/uebung10/logo/HanselGretelVisitor$LongUpSate.class deleted file mode 100644 index 7127ca37ced012dd1026d6bd22352fb158b4ac10..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 798 zcma)3%TB^T6g{^s?<$Bdd}}0%U_ckHd?W_qBOz{3_C+SOrglgl`du!Ji3>l#k22m? zqQsEYMQ7&R-gC~KGasLC?*LA*k%B_l4MZ<+%>BKFElt_DFdR?V=dSRD-L*W+mu|T& z9rI?;F?^ANM%a#LbbM|mB>g+fEAJ6D+p(NOZa=ad%ReD(RsPYx((kpiGgQTOv(0@RyYOq z`D<}47!cG-G+19gIfQIS2JWpmvqJyUm~89!#-l;dFC9m?P22E1;ia%b*oX~`)qfv` zkQip3z7n2)Aw3`KoQujYO@%@j4xcnAVK`jRFgjqQ@SdyIUXZQUUZFoTR4~bFlAC}- z4!*|!E7WphxwsIjRiw1`YUlf;{7X8iYK0o eA*xtl4+V=@iY}nA=Q38gqVm3`DV$dLfB6eOsGZRO diff --git a/bin/uebung10/logo/HanselGretelVisitor$ShortUpState.class b/bin/uebung10/logo/HanselGretelVisitor$ShortUpState.class index c4c6307b45f61fcd3c28fd0a24e48f61bcd37231..ba642a73a20efa4deec3b37e2b8d9399e214e1ee 100644 GIT binary patch delta 31 mcmZ3&wuEhi5ffv?WMd`^#>mMzOiqkZlh*^;(UV^=*#H2JPYD|U delta 31 mcmZ3&wuEhi5fh{PWMd`^MvuukOiqlRlh*^;UXx!i*#H2Fmk8GY diff --git a/bin/uebung10/logo/HanselGretelVisitor$State.class b/bin/uebung10/logo/HanselGretelVisitor$State.class index 2817f07cab9f530cd5d5913a1e61c657d0a4db9b..823ded1407e01ab125963cee7ad520fe08751f1c 100644 GIT binary patch delta 25 hcmZ3&x`cJZS4Kvw$=?_q7;Pq-Gg&a&PA*_F0RV9-2etqJ delta 25 hcmZ3&x`cJZS4Kv|$=?_q7>y^JGg&a2OfFzD0RV6T2b%x@ diff --git a/bin/uebung10/logo/HanselGretelVisitor.class b/bin/uebung10/logo/HanselGretelVisitor.class index 5484ad8ae660fc6f2fb43ec171aa62d4a79baaec..5a1d894e1b4462b45a60393b66549c110dc0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iK=J62?iHBHj6` z$66j8ibW@WL03=9t^;!;nLjWe!Q}^0wQEc4=g0qOV^Lj$PMzBUW@3=}AK+hF8|~Fu zO|2VE;VoRFv2JGmZM;Ks@6sGI_n1YB8&C!pzT)#e@Io?o-FNMjA8j&2->fy__kgzSQyozM|~oeJ`25 d=9>Y^Zzy{xzolHJ{4N&3_tZ;jy#c;k{tuEhqqP74 diff --git a/src/uebung10/logo/HanselGretelTest.java b/src/uebung10/logo/HanselGretelTest.java new file mode 100644 index 0000000..d68d8a9 --- /dev/null +++ b/src/uebung10/logo/HanselGretelTest.java @@ -0,0 +1,30 @@ +package uebung10.logo; + +import org.junit.Test; +import static org.junit.Assert.assertEquals; + +import org.junit.Before; + +public class HanselGretelTest { + + public static final double EPS = 1e-10; + public static final Stmt PROG = new Sequence(new PenDown(), new Go(50), + new Turn(120), new Go(50), + new Turn(120), new Go(50)); + + private Turtle turtle; + + @Before + public void setup() { + turtle = new Turtle(2, 1, 0); + } + + @Test + public void TestTriangle() { + final Visitor visitor = new HanselGretelVisitor(10, turtle, new BlackForest()); //final ist egal + PROG.accept(visitor); + assertEquals(2, turtle.getX(), EPS); + assertEquals(1, turtle.getY(), EPS); + } + +} diff --git a/src/uebung10/logo/HanselGretelVisitor.java b/src/uebung10/logo/HanselGretelVisitor.java index da1a7f0..8fe1f5c 100644 --- a/src/uebung10/logo/HanselGretelVisitor.java +++ b/src/uebung10/logo/HanselGretelVisitor.java @@ -46,6 +46,15 @@ public class HanselGretelVisitor implements Visitor { return null; } + private void breadCrumb() { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'breadCrumb'"); + } + + private void layTrail(double d) { + forest.breadCrumb(turtle.getX(), turtle.getY()); + } + private abstract class State { abstract void go(double dist); void up() {} @@ -54,20 +63,28 @@ public class HanselGretelVisitor implements Visitor { private final State shortUp = new ShortUpState();// muss nicht geschrieben werden private final State down = new DownState();// muss nicht geschrieben werden - private final State longUp = new LongUpSate(); + private final State longUp = new State(){ - private class LongUpSate extends State{ - void go(double d) {} - void up(){} - void down(){} - } + @Override + void go(double d) {turtle.go(d);} + + @Override + void down(){ + breadCrumb(); + state = down; + } + + }; private class DownState extends State{ - void go(double d){} - void up(){} - void down(){} + void go(double d){ + layTrail(d); + } + + void up(){state = shortUp;} } + //TODO private class ShortUpState extends State { void go(double d){} void up(){}