doc aze
public class Point3D { float x; float y; float z; Point3D(float x,float y,float z){ this.x=x; this.y=y; this.z=z; } }
package pkg3d;
public abstract class Forme { private Point3D centre; private float densiter;
Point3D getCentre(){return centre;} void setCentre(Point3D c){centre=c;}
float getDensiter(){return densiter;} void setDensiter(float d){densiter=d;}
Forme (Point3D centre,float densiter){ this.centre=centre; this.densiter=densiter;}
public void bouger(float dx,float dy,float dz){ centre.x=centre.x+dx; centre.y=centre.y+dy; centre.z=centre.z+dz;}
public abstract double calculerSurface(); public abstract double calculerVolume ();
public double calculerPoids (){return densiter*this.calculerVolume();}
public String toString(){ return("centre de gravité: ("+centre.x+" , "+centre.y+" , "+centre.z+")\ndensité: "+densiter);}
public static boolean comparer(Forme f1, Forme f2){ boolean egale=false; if((f1 instanceof Boule) &&(f2 instanceof Boule)) { if ((f1.centre==f2.centre) && (f1.densiter)==(f2.densiter) &&(((Boule)f1).rayon==((Boule)f2).rayon) ) egale=true;} else {if((f1 instanceof Brique) &&(f2 instanceof Brique)){ if((f1.centre==f2.centre) && (f1.densiter)==(f2.densiter)&&(((Brique)f1).getLargeur()==((Brique)f2).getLargeur()) &&(((Brique)f1).getLongueur()==((Brique)f2).getLongueur())&&(((Brique)f1).getHauteur()==((Brique)f2).getLargeur())) egale=false;}} return egale;
}
}
package pkg3d;
public class Brique extends Forme{ private double largeur,longueur , hauteur; Brique(Point3D centre,float densiter,double largeur,double longueur,double hauteur){ super(centre,densiter); this.largeur=largeur; this.longueur=longueur; this.hauteur=hauteur; } double