Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package cz.czechitas.beginnerjava.homework.practice;
- import org.teachingextensions.logo.Turtle;
- public class Spiral {
- public static void main(String[] args) {
- Spiral myApp = new Spiral();
- myApp.run();
- }
- Turtle turtle = new Turtle();
- public void run() {
- turtle.show();
- turtle.setSpeed(10);
- /*
- * 1.i - 5
- * 2.i - 5 + 10
- * 3.i - 5 + 20
- * 4.i - (5 + 30)
- * y.1 - x
- * x = initial length +??
- * (5+30), (5+20), (5+10) = X
- * y i = x / 10 - 5 / 10 + 1
- * 10 y = x -5 + 10
- * x = 10y + 5 -10
- * 5 = initial length
- * 10 = addition to each length
- */
- int initialLength = 5;
- int addition = 5;
- for (int i = 1; i < 50; i++) {
- turtle.move((addition * i) + (initialLength - addition));
- turtle.turn(90);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement