## Practice Exercises Java

Learn to program performing exercises with Java

## 12 Lessons Java with the Solutions - 228 Exercises Java with the solutions For Beginners, Intermediates and Advanceds

The human knowledge belongs to the world
¡The infomation should be free!

# 3D point - Practice Exercises Java

## Source Code:

``````public class Main
{
protected double x, y, z;

public Point3D()
{
}

public Point3D(double nx, double ny, double nz)
{
MoveTo(nx, ny, nz);
}

public final double GetX()
{
return x;
}

public final void SetX(double value)
{
x = value;
}

public final double GetY()
{
return y;
}

public final void SetY(double value)
{
y = value;
}

public final double GetZ()
{
return z;
}

public final void SetZ(double value)
{
z = value;
}

public final void MoveTo(double nx, double ny, double nz)
{
x = nx;
y = ny;
z = nz;
}

public final double DistanceTo(Point3D p2)
{
return Math.sqrt((x - p2.GetX()) * (x - p2.GetX()) + (y - p2.GetY()) * (y - p2.GetY()) + (z - p2.GetZ()) * (z - p2.GetZ()));
}
}``````
Exercisey 7.12