import java.applet.*;
import java.awt.*;

public class Programm2 extends Applet {
  // Globale Variablen (Instanzvariablen) deklarieren
  int x, y;

  public Programm2() {
    // Globale Variablen initialisieren
    x=250;
    y=50;
  }

  public void paint(Graphics Stift) {
    // Lokale Variablen deklarieren und initialisieren
    int x=0, y=250;
    // Lokale Variable i für for-Schleife deklarieren und initialisieren
    for(int i=0; i<50; i=i+10) {
      // Aufruf der globalen Variablen x und y durch Vorstellen von this
      Stift.drawOval(this.x-i,this.y-i,2*i,2*i);
    }
    // While-Schleife wird solange wiederholt, wie x<400 ist
    while(x<400) {
      Stift.setColor(Color.GREEN);
      // Konversion des Rechenergebnisses durch (int)-Cast
      Stift.drawRect(x,(int)(Math.sin(x*Math.PI/100)*50+100),1,1);
      // Der nachfolgende {}-Block wird nur ausgeführt, wenn x<=255 ist
      if(x<=255) {
        // new Color(x,200,255) ergibt eine neue Farbe nach dem RGB-Maß
        Stift.setColor(new Color(x,0,255));
      }
      // Wenn x>255 ist, wird der {}-Block nach else ausgeführt
      else {
        Stift.setColor(new Color(255,0,511-x));
      }
      // Eine Parabel wird gezeichnet
      Stift.drawRect(x,y-(int)((x-200)*(x-200)/300),1,1);
      // Die Variable x wird um eins erhöht: x++ oder x=x+1 oder x+=1
      x++;
    }
  }

}

