Solved Task 1

This commit is contained in:
schrom01 2022-10-17 16:30:01 +02:00
parent d5fabaf522
commit 17945a953d
2 changed files with 31 additions and 2 deletions

View File

@ -6,7 +6,7 @@ import org.junit.jupiter.api.Test;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
/*
public class ADS4_1_test { public class ADS4_1_test {
SnowflakeServer sf; SnowflakeServer sf;
Turtle turtle; Turtle turtle;
@ -98,4 +98,3 @@ public class ADS4_1_test {
} }
} }
} }
*/

View File

@ -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);
}
}
}