Record Class Point
java.lang.Object
java.lang.Record
it.unimi.di.prog2.s17.Point
- Record Components:
x- the x coordinate.y- the y coordinate.z- the z coordinate.
Immutable three-dimensional point with integer coordinates.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.longnorm()Returns the l1 norm of this point.signum()Returns a point with coordinates -1, 0, or 1 depending on the sign of the coordinates of this point.Returns the difference between this point and the given point.Returns the sum of this point and the given point.toString()Returns a string representation of this record class.intx()Returns the value of thexrecord component.inty()Returns the value of theyrecord component.intz()Returns the value of thezrecord component.
-
Field Details
-
Constructor Details
-
Point
-
-
Method Details
-
sum
Returns the sum of this point and the given point.- Parameters:
q- the point to be added to this point.- Returns:
- the sum.
- Throws:
NullPointerException- if q is null.
-
subtract
Returns the difference between this point and the given point.- Parameters:
q- the point to be subtracted from this point.- Returns:
- the difference.
- Throws:
NullPointerException- if q is null.
-
norm
public long norm()Returns the l1 norm of this point.- Returns:
- the norm.
-
signum
Returns a point with coordinates -1, 0, or 1 depending on the sign of the coordinates of this point.- Returns:
- a point with coordinates representing the sign of this point's coordinates.
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with thecomparemethod from their corresponding wrapper classes. -
x
-
y
-
z
-