Skip to content
Snippets Groups Projects
Quader.java 1.2 KiB
Newer Older
public class Quader extends Koerper {
    
    private double a;
    private double b;
    private double c;
    
    public Quader( double x, double y, double z, double a, double b, double c ) {
        super(x, y, z);
        
        this.a = a;
        this.b = b;
        this.c = c;
    }
    
    public double berechneOberflaeche() {
        return 2 * a * b + 2 * a * c + 2 * b * c;
    }

    public double berechneVolumen() {
        return a * b * c;
    }
    
    public String getParameter() {
        return this.istEin() + " mit den Maßen " + this.a + " x " + this.b + " x " + this.c ;
    }

    // TODO: implement the right 	algorithm to check that a point is inside a square
    public boolean istImKoerper( double x, double y, double z ) {
        if (  (x <= this.getX() + a) || (x >= this.getX() + a) ) {
            return false;
        } else if (  (y <= this.getY() + b) || (y >= this.getY() + b) ) {
            return false;
        } else if (  (z <= this.getZ() + c) || (z >= this.getZ() + c) ) {
            return false;
        } else {
            return true;
        }
    }

    public void skaliere(double alpha) {
        a = a + alpha;
        b = b + alpha;
        c = c + alpha;
    }
}