Skip to content
Snippets Groups Projects
Commit b0be1169 authored by Jan Kožusznik's avatar Jan Kožusznik
Browse files

Change to double

parent d83b0043
No related merge requests found
package cz.vsb.java1.test2;
import java.util.Objects;
import cz.vsb.java1.test2.helpers.RandomGenarator;
public class Vector3D {
private String name;
private int x;
private int y;
private int z;
private double x;
private double y;
private double z;
public static Vector3D generate() {
return new Vector3D(RandomGenarator.generateRandomVectorName(), // name
......@@ -34,27 +36,27 @@ public class Vector3D {
this.name = name;
}
public int getX() {
public double getX() {
return x;
}
public void setX(int x) {
public void setX(double x) {
this.x = x;
}
public int getY() {
public double getY() {
return y;
}
public void setY(int y) {
public void setY(double y) {
this.y = y;
}
public int getZ() {
public double getZ() {
return z;
}
public void setZ(int z) {
public void setZ(double z) {
this.z = z;
}
......@@ -71,15 +73,10 @@ public class Vector3D {
return "Vector3D [name=" + name + ", x=" + x + ", y=" + y + ", z=" + z + "]";
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((name == null) ? 0 : name.hashCode());
result = prime * result + x;
result = prime * result + y;
result = prime * result + z;
return result;
return Objects.hash(name, x, y, z);
}
@Override
......@@ -91,18 +88,9 @@ public class Vector3D {
if (getClass() != obj.getClass())
return false;
Vector3D other = (Vector3D) obj;
if (name == null) {
if (other.name != null)
return false;
} else if (!name.equals(other.name))
return false;
if (x != other.x)
return false;
if (y != other.y)
return false;
if (z != other.z)
return false;
return true;
return Objects.equals(name, other.name) && Double.doubleToLongBits(x) == Double.doubleToLongBits(other.x)
&& Double.doubleToLongBits(y) == Double.doubleToLongBits(other.y)
&& Double.doubleToLongBits(z) == Double.doubleToLongBits(other.z);
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment