Skip to content
Snippets Groups Projects
Commit b1fa800d authored by PIERRON Laurent's avatar PIERRON Laurent :man_in_tuxedo_tone1:
Browse files

Correction de computeVolume() mise au cube au lieu du carré. Respect des indications SonarLint.

parent dd694a9e
No related branches found
No related tags found
No related merge requests found
...@@ -10,53 +10,53 @@ public class Sphere { ...@@ -10,53 +10,53 @@ public class Sphere {
// Constructors // Constructors
// *********************************************************************** // ***********************************************************************
public Sphere() { public Sphere() {
radius_ = 0.0; radiusProtected = 0.0;
pos_ = new Point3d(); posProtected = new Point3d();
} }
public Sphere(double radius) { public Sphere(double radius) {
radius_ = radius; radiusProtected = radius;
pos_ = new Point3d(); posProtected = new Point3d();
} }
public Sphere(double radius, Point3d pos) { public Sphere(double radius, Point3d pos) {
radius_ = radius; radiusProtected = radius;
pos_ = pos; posProtected = pos;
} }
// *********************************************************************** // ***********************************************************************
// Methods // Methods
// *********************************************************************** // ***********************************************************************
public double computeVolume() { public double computeVolume() {
return 4 * Math.PI * Math.pow(radius_, 2) / 3; return 4 * Math.PI * Math.pow(radiusProtected, 3) / 3;
} }
public double distanceTo(Sphere other) { public double distanceTo(Sphere other) {
return pos_.distance(other.pos_); return posProtected.distance(other.posProtected);
} }
public double distanceSquaredTo(Sphere other) { public double distanceSquaredTo(Sphere other) {
return pos_.distanceSquared(other.pos_); return posProtected.distanceSquared(other.posProtected);
} }
public boolean inContactWith(Sphere other) { public boolean inContactWith(Sphere other) {
return distanceSquaredTo(other) <= Math.pow(radius_ + other.radius_, 2); return distanceSquaredTo(other) <= Math.pow(radiusProtected + other.radiusProtected, 2);
} }
// *********************************************************************** // ***********************************************************************
// Accessors // Accessors
// *********************************************************************** // ***********************************************************************
public Point3d getPos() { public Point3d getPos() {
return pos_; return posProtected;
} }
public double getRadius() { public double getRadius() {
return radius_; return radiusProtected;
} }
// *********************************************************************** // ***********************************************************************
// Attributes // Attributes
// *********************************************************************** // ***********************************************************************
protected double radius_ = 0.0; protected double radiusProtected = 0.0;
protected Point3d pos_; protected Point3d posProtected;
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment