Advertisement
Guest User

Untitled

a guest
Apr 1st, 2020
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. package cz.czechitas.beginnerjava.homework.practice;
  2.  
  3. import org.teachingextensions.logo.Turtle;
  4.  
  5. public class Spiral {
  6. public static void main(String[] args) {
  7. Spiral myApp = new Spiral();
  8. myApp.run();
  9. }
  10.  
  11. Turtle turtle = new Turtle();
  12.  
  13. public void run() {
  14. turtle.show();
  15. turtle.setSpeed(10);
  16.  
  17.  
  18. /*
  19. * 1.i - 5
  20. * 2.i - 5 + 10
  21. * 3.i - 5 + 20
  22. * 4.i - (5 + 30)
  23. * y.1 - x
  24. * x = initial length +??
  25. * (5+30), (5+20), (5+10) = X
  26. * y i = x / 10 - 5 / 10 + 1
  27. * 10 y = x -5 + 10
  28. * x = 10y + 5 -10
  29. * 5 = initial length
  30. * 10 = addition to each length
  31. */
  32.  
  33.  
  34. int initialLength = 5;
  35. int addition = 5;
  36. for (int i = 1; i < 50; i++) {
  37. turtle.move((addition * i) + (initialLength - addition));
  38. turtle.turn(90);
  39. }
  40.  
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement