Compare commits

..

2 Commits

Author SHA1 Message Date
7fea13b9b3 MINAS??? 2024-06-17 22:33:20 +02:00
639da57def MINAS 2024-06-17 22:33:01 +02:00
25 changed files with 107 additions and 4 deletions

Binary file not shown.

Binary file not shown.

BIN
bin/uebung10/logo/Go.class Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,4 +1,4 @@
package logo; package uebung10.logo;
public interface DarkForest { public interface DarkForest {
void breadCrumb(double x, double y); void breadCrumb(double x, double y);

View File

@ -1,4 +1,4 @@
package logo; package uebung10.logo;
public class Demo { public class Demo {
public static void main(String[] args) { public static void main(String[] args) {

19
src/uebung10/logo/Go.java Normal file
View File

@ -0,0 +1,19 @@
package uebung10.logo;
public class Go implements Stmt{
public final double dist;
public Go(double dist) {
if (dist < 0) {
throw new IllegalArgumentException();
} else {
this.dist = dist;
}
}
@Override
public <T> T accept(Visitor<T> visitor) {
return visitor.visit(this);
}
}

View File

@ -1,4 +1,4 @@
package logo; package uebung10.logo;
import javax.swing.JFrame; import javax.swing.JFrame;
import javax.swing.JPanel; import javax.swing.JPanel;

View File

@ -0,0 +1,18 @@
package uebung10.logo;
public class HanselGretelVisitor implements Visitor<Turtle> {
private double gap;
private double s;
private Turtle turtle;
private DarkForest forest;
public HanselGretelVisitor(double s, Turtle turtle, DarkForest forest) {
this.s = s;
this.turtle = turtle;
this.forest = forest;
}
}

View File

@ -0,0 +1,9 @@
package uebung10.logo;
public class PenDown implements Stmt{
@Override
public <T> T accept(Visitor<T> visitor) {
return visitor.visit(this);
}
}

View File

@ -0,0 +1,9 @@
package uebung10.logo;
public class PenUp implements Stmt {
@Override
public <T> T accept(Visitor<T> visitor) {
return visitor.visit(this);
}
}

View File

@ -0,0 +1,15 @@
package uebung10.logo;
public class Sequence implements Stmt {
public final Stmt[] seq;
public Sequence(Stmt... seq) {
this.seq = seq;
}
@Override
public <T> T accept(Visitor<T> visitor) {
return visitor.visit(this);
}
}

View File

@ -0,0 +1,7 @@
package uebung10.logo;
public interface Stmt {
public <T> T accept(Visitor<T> visitor);
}

View File

@ -0,0 +1,15 @@
package uebung10.logo;
public class Turn implements Stmt{
public final double angle;
public Turn(double angle) {
this.angle = angle;
}
@Override
public <T> T accept(Visitor<T> visitor) {
return visitor.visit(this);
}
}

View File

@ -1,4 +1,4 @@
package logo; package uebung10.logo;
public class Turtle { public class Turtle {
private double x; private double x;

View File

@ -0,0 +1,11 @@
package uebung10.logo;
public interface Visitor<T> {
T visit(PenUp penUp);
T visit(PenDown penDown);
T visit(Turn turn);
T visit(Sequence sequence);
T visit(Go go);
}