import java.awt.*;
import java.applet.*;

public class Flohhuepfen3 extends Applet
{
  Turtle t;
  public void paint(Graphics g)
  {
    t = new Turtle(this, 100, 150, 0);
    zeichne();   // Aufruf des Hauptprogramms
  }

  void zeichne() // Hauptprogramm
  { double xMin = -0.8;
    double xMax =  0.0;
    double yMin = -0.2;
    double yMax =  0.4;
    t.setzeKOS(xMin, xMax, yMin, yMax);
    int sprungAnzahl = 5000; // faellt nicht vom Tisch
    double cx = -0.731;
    double cy = 0.15;
    double x  = 0;
    double y  = 0;
    double neux = 0;
    double neuy = 0;
    double betragsQuadrat = 0;
    int farbNummer = 0;
    int sprungNummer = 1;

    t.stiftHoch();
    t.geheZu(x,y);
    t.stiftRunter();

    while ((sprungNummer <= sprungAnzahl) && (betragsQuadrat < 4))
    {
       sprungNummer++;
       neux = x*x - y*y + cx;
       neuy = 2*x*y + cy;
       farbNummer = sprungNummer%500;
       if (farbNummer<100) t.stiftfarbe(Color.blue);
       else if (farbNummer<200) t.stiftfarbe(Color.green);
       else if (farbNummer<300) t.stiftfarbe(Color.red);
       else if (farbNummer<400) t.stiftfarbe(Color.pink);
       else if (farbNummer<500) t.stiftfarbe(Color.yellow);
       t.geheZu(x,y);
       x = neux;
       y = neuy;
       betragsQuadrat = x*x + y*y;
    } // end while

    if (betragsQuadrat>4) t.schreibe ("Heruntergefallen!",0,0);
  }  // zeichne

} // class Einstieg

