Package it.unimi.di.prog2.s18
Record Class Point
java.lang.Object
java.lang.Record
it.unimi.di.prog2.s18.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 boolean
Indicates whether some other object is "equal to" this one.final int
hashCode()
Returns a hash code value for this object.long
norm()
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.int
x()
Returns the value of thex
record component.int
y()
Returns the value of they
record component.int
z()
Returns the value of thez
record component.
-
Field Details
-
Constructor Details
-
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
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
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 '=='. -
x
public int x()Returns the value of thex
record component.- Returns:
- the value of the
x
record component
-
y
public int y()Returns the value of they
record component.- Returns:
- the value of the
y
record component
-
z
public int z()Returns the value of thez
record component.- Returns:
- the value of the
z
record component
-