Skip to content
Snippets Groups Projects
Kugel.java 842 B
Newer Older
public class Kugel extends Koerper {
    
    private double radius;
    
    public Kugel( double x, double y, double z, double radius ) {
        super(x, y, z);
        
        this.radius = radius;
    }

    public double berechneOberflaeche() {
        return 4 * Math.PI * Math.pow(radius, 2);
    }

    public double berechneVolumen() {
        return (4 * Math.PI * Math.pow(radius, 3))/3;
    }
    
    public String getParameter() {
        return this.istEin() + " mit dem Radius " + radius;
    }

    public boolean istImKoerper( double x, double y, double z ) {
        if ( (Math.pow(x, 2)  +  Math.pow(y, 2)  + Math.pow(z, 2))  <=  Math.pow(radius, 2) ) {
            return true;
        } else {
            return false;
        }
    }

    public void skaliere(double alpha) {
        radius = radius + alpha;
    }
}