diff --git a/src/ch/zhaw/ads/ADS4_1_test.java b/src/ch/zhaw/ads/ADS4_1_test.java index c5a65bc..1dce82c 100644 --- a/src/ch/zhaw/ads/ADS4_1_test.java +++ b/src/ch/zhaw/ads/ADS4_1_test.java @@ -6,7 +6,7 @@ import org.junit.jupiter.api.Test; import java.util.StringTokenizer; import static org.junit.jupiter.api.Assertions.assertEquals; -/* + public class ADS4_1_test { SnowflakeServer sf; Turtle turtle; @@ -98,4 +98,3 @@ public class ADS4_1_test { } } } -*/ \ No newline at end of file diff --git a/src/ch/zhaw/ads/SnowflakeServer.java b/src/ch/zhaw/ads/SnowflakeServer.java new file mode 100644 index 0000000..9e8a4cb --- /dev/null +++ b/src/ch/zhaw/ads/SnowflakeServer.java @@ -0,0 +1,30 @@ +package ch.zhaw.ads; + +public class SnowflakeServer implements CommandExecutor { + double distanz = 1.0; + Turtle turtle; + + @Override + public String execute(String command) { + turtle = new Turtle(); + int steps = Integer.parseInt(command); + drawSnowFlake(steps, distanz); + return turtle.getTrace(); + } + + public void drawSnowFlake(int steps, double distanz){ + if(steps == 0) { + turtle.move(distanz); + } else { + distanz = distanz / 3; + steps--; + drawSnowFlake(steps, distanz); + turtle.turn(60); + drawSnowFlake(steps, distanz); + turtle.turn(-120); + drawSnowFlake(steps, distanz); + turtle.turn(60); + drawSnowFlake(steps, distanz); + } + } +}