diff --git a/bin/test/uebung/uebung09/collection/SetTest.class b/bin/test/uebung/uebung09/collection/SetTest.class deleted file mode 100644 index 1aa1f92..0000000 Binary files a/bin/test/uebung/uebung09/collection/SetTest.class and /dev/null differ diff --git a/bin/uebung09/collection/BigSet$1.class b/bin/uebung09/collection/BigSet$1.class deleted file mode 100644 index 5479c6d..0000000 Binary files a/bin/uebung09/collection/BigSet$1.class and /dev/null differ diff --git a/bin/uebung09/collection/BigSet.class b/bin/uebung09/collection/BigSet.class deleted file mode 100644 index 9997eb4..0000000 Binary files a/bin/uebung09/collection/BigSet.class and /dev/null differ diff --git a/bin/uebung09/collection/EmptySet$1.class b/bin/uebung09/collection/EmptySet$1.class deleted file mode 100644 index d2706cf..0000000 Binary files a/bin/uebung09/collection/EmptySet$1.class and /dev/null differ diff --git a/bin/uebung09/collection/EmptySet.class b/bin/uebung09/collection/EmptySet.class deleted file mode 100644 index 73456b7..0000000 Binary files a/bin/uebung09/collection/EmptySet.class and /dev/null differ diff --git a/bin/uebung09/collection/SetFactory.class b/bin/uebung09/collection/SetFactory.class index 4762368..15c139e 100644 Binary files a/bin/uebung09/collection/SetFactory.class and b/bin/uebung09/collection/SetFactory.class differ diff --git a/bin/uebung09/collection/SingeltonSet$1.class b/bin/uebung09/collection/SingeltonSet$1.class deleted file mode 100644 index 427fab0..0000000 Binary files a/bin/uebung09/collection/SingeltonSet$1.class and /dev/null differ diff --git a/bin/uebung09/collection/SingeltonSet.class b/bin/uebung09/collection/SingeltonSet.class deleted file mode 100644 index 8624d52..0000000 Binary files a/bin/uebung09/collection/SingeltonSet.class and /dev/null differ diff --git a/bin/uebung10/logo/Go.class b/bin/uebung10/logo/Go.class index aecb3b4..f6bbceb 100644 Binary files a/bin/uebung10/logo/Go.class and b/bin/uebung10/logo/Go.class differ diff --git a/bin/uebung10/logo/HanselGretelVisitor$DownState.class b/bin/uebung10/logo/HanselGretelVisitor$DownState.class new file mode 100644 index 0000000..c14b60a Binary files /dev/null and b/bin/uebung10/logo/HanselGretelVisitor$DownState.class differ diff --git a/bin/uebung10/logo/HanselGretelVisitor$LongUpSate.class b/bin/uebung10/logo/HanselGretelVisitor$LongUpSate.class new file mode 100644 index 0000000..7127ca3 Binary files /dev/null and b/bin/uebung10/logo/HanselGretelVisitor$LongUpSate.class differ diff --git a/bin/uebung10/logo/HanselGretelVisitor$ShortUpState.class b/bin/uebung10/logo/HanselGretelVisitor$ShortUpState.class new file mode 100644 index 0000000..c4c6307 Binary files /dev/null and b/bin/uebung10/logo/HanselGretelVisitor$ShortUpState.class differ diff --git a/bin/uebung10/logo/HanselGretelVisitor$State.class b/bin/uebung10/logo/HanselGretelVisitor$State.class new file mode 100644 index 0000000..2817f07 Binary files /dev/null and b/bin/uebung10/logo/HanselGretelVisitor$State.class differ diff --git a/bin/uebung10/logo/HanselGretelVisitor.class b/bin/uebung10/logo/HanselGretelVisitor.class index 8d47158..5484ad8 100644 Binary files a/bin/uebung10/logo/HanselGretelVisitor.class and b/bin/uebung10/logo/HanselGretelVisitor.class differ diff --git a/bin/uebung10/logo/Sequence.class b/bin/uebung10/logo/Sequence.class index b6c9d5e..799dbb8 100644 Binary files a/bin/uebung10/logo/Sequence.class and b/bin/uebung10/logo/Sequence.class differ diff --git a/src/uebung10/logo/Go.java b/src/uebung10/logo/Go.java index 1f82e80..b3b1e7d 100644 --- a/src/uebung10/logo/Go.java +++ b/src/uebung10/logo/Go.java @@ -7,9 +7,8 @@ public class Go implements Stmt{ public Go(double dist) { if (dist < 0) { throw new IllegalArgumentException(); - } else { - this.dist = dist; } + this.dist = dist; } @Override diff --git a/src/uebung10/logo/HanselGretelVisitor.java b/src/uebung10/logo/HanselGretelVisitor.java index ab0c6b0..da1a7f0 100644 --- a/src/uebung10/logo/HanselGretelVisitor.java +++ b/src/uebung10/logo/HanselGretelVisitor.java @@ -1,11 +1,12 @@ package uebung10.logo; -public class HanselGretelVisitor implements Visitor { +public class HanselGretelVisitor implements Visitor { private double gap; private double s; private Turtle turtle; private DarkForest forest; + private State state; public HanselGretelVisitor(double s, Turtle turtle, DarkForest forest) { this.s = s; @@ -13,6 +14,76 @@ public class HanselGretelVisitor implements Visitor { this.forest = forest; } - + @Override + public Void visit(PenUp penUp) { + up(); + return null; + } + @Override + public Void visit(PenDown penDown) { + down(); + return null; + } + + @Override + public Void visit(Turn turn) { + turtle.turn(turn.angle); + return null; + } + + @Override + public Void visit(Sequence sequence) { + for(Stmt elem :sequence.seq) { + elem.accept(this); + } + return null; + } + + @Override + public Void visit(Go go) { + go(go.dist); + return null; + } + + private abstract class State { + abstract void go(double dist); + void up() {} + void down() {} + } + + 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 class LongUpSate extends State{ + void go(double d) {} + void up(){} + void down(){} + } + + private class DownState extends State{ + void go(double d){} + void up(){} + void down(){} + } + + private class ShortUpState extends State { + void go(double d){} + void up(){} + void down(){} + } + + + private void go(double d) { + state.go(d); + } + + private void down() { + state.down(); + } + + private void up() { + state.up(); + } } diff --git a/src/uebung10/logo/Sequence.java b/src/uebung10/logo/Sequence.java index c367701..5358041 100644 --- a/src/uebung10/logo/Sequence.java +++ b/src/uebung10/logo/Sequence.java @@ -5,7 +5,7 @@ public class Sequence implements Stmt { public final Stmt[] seq; public Sequence(Stmt... seq) { - this.seq = seq; + this.seq = seq.clone(); } @Override