All methods should take Object and throw a NumberFormatException if the object is not of the required type. This will make printing error messages much easier.
Example:
public Vector3D multiply(Object o) throws NumberFormatException {
if(o.getClass() == Vector3D.class)
...vector dot product...
else if(o.getClass() == Double.class)
...scalar multiplication...
else
throw new NumberFormatException("Error: invalid type. The * operator requires an object of type Vector3D or double");
}
All methods should take Object and throw a NumberFormatException if the object is not of the required type. This will make printing error messages much easier.
Example:
public Vector3D multiply(Object o) throws NumberFormatException {
if(o.getClass() == Vector3D.class)
...vector dot product...
else if(o.getClass() == Double.class)
...scalar multiplication...
else
throw new NumberFormatException("Error: invalid type. The * operator requires an object of type Vector3D or double");
}