Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a class named Point that represent points in in three dimensional space t

ID: 3826059 • Letter: C

Question

Create a class named Point that represent points in in three dimensional space that has the following properties: It contains three double variables x, y, z representing the components as instance variables. It includes a default constructor that initialize x, y. and z to 0. It include a constructor that requires three arguments one for each component with default value of 0. It include a method to translate (m0ve) the point by dx, dy, and dz in the x, y. and z direction respectively. That is new x component should become x + dx.

Explanation / Answer

class Point{

double x;
double y;
double z;

Point()
{
this.x = 0.0;
this.y = 0.0;
this.z = 0.0;
}

Point(double x, double y , double z)
{
if(x != 0.0)
this.x = x;
else
this.x = 0.0;
if(y != 0.0)
this.y = y;
else
this.y = 0.0;
if(z != 0.0)
this.z = z;
else
this.z = 0.0;
}

void translate(double d)
{
x = x+d*x;
y = y+d*y;
z = z+d*z;
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote