 import java.awt.*;
/**
 *
 * Beschreibung
 *
 * @version 1.0
 * @author Cellum
 */

public class Kreis extends Figur{
  //Attribute der Klasse Kreis
  private final int durchmesser;
  private final int x;
  private final int y;
  private final int radius;
  
  //Konstruktor
  public Kreis(int x, int y, int d, Color farbe){
    super(x,y,farbe);
    this.durchmesser = d;
    this.radius = d/2;
    this.x = x;
    this.y = y;
    }
  
  public void draw (Graphics g){
    super.draw(g);
    g.fillOval(x - radius, y - radius, durchmesser, durchmesser);
    }
  public double getFlaecheninhalt()
  {
    return Math.PI*radius*radius;
  }

  public int getRadius()
  {
    return radius;
  }
  @Override
  public boolean enthaeltPunkt(int x, int y) {
    // Berechne den Abstand zwischen dem Punkt (x, y) und dem Mittelpunkt des Kreises
    int abstandX = x - this.x;
    int abstandY = y - this.y;
    return radius * radius >= abstandX * abstandX + abstandY * abstandY;

    // Überprüfe, ob der Abstand kleiner oder gleich dem Radius des Kreises ist
  }
}