import java.awt.Color;
import sk.upjs.jpaz2.Turtle;
public class ChytraKorytnacka extends Turtle {
public void pohorie(double rameno, double zakladna) {
for (int i = 0; i < 5; i++) {
this.turn(30);
this.step(rameno);
this.turn(60);
this.step(zakladna);
this.turn(60);
this.step(rameno);
this.turn(-150);
}
this.turn(-90);
this.step(5 * (zakladna + rameno));
this.turn(90);
}
public void pochodzkaKruh(int pocetKrokov, double polomer) {
double xStart = this.getX();
double yStart = this.getY();
for (int i = 0; i < pocetKrokov; i++) {
this.turn(Math.random() * 360);
this.step(5);
if (this.distanceTo(xStart, yStart) > polomer) {
this.step(-5);
}
}
this.setPosition(xStart, yStart);
}
public void pochodzkaTrojkruh(int pocetKrokov, double polomer) {
double xStart = this.getX();
double yStart = this.getY();
for (int i = 0; i < pocetKrokov; i++) {
this.turn(Math.random() * 360);
if (this.distanceTo(xStart, yStart) < polomer / 3) {
this.penUp();
} else {
this.penDown();
}
if (this.distanceTo(xStart, yStart) < 2 * polomer / 3) {
this.setPenColor(Color.blue);
} else {
this.setPenColor(Color.red);
}
this.step(5);
if (this.distanceTo(xStart, yStart) > polomer) {
this.step(-5);
}
}
this.setPosition(xStart, yStart);
}
public void pochodzkaStvorec(int pocetKrokov, double strana) {
double xStart = this.getX();
double yStart = this.getY();
for (int i = 0; i < pocetKrokov; i++) {
this.turn(Math.random() * 360);
this.step(5);
boolean jeVXPase = (this.getX() >= xStart-strana/2) && (this.getX() <= xStart+strana/2);
boolean jeVYPase = (this.getY() >= yStart-strana/2) && (this.getY() <= yStart+strana/2);
if (!(jeVXPase && jeVYPase)) {
this.step(-5);
}
}
this.setPosition(xStart, yStart);
}
}