Record Class Poly.Term
java.lang.Object
java.lang.Record
it.unimi.di.prog2.h18.Poly.Term
- Record Components:
coefficient- the coefficient of the term.degree- the degree of the term.
- Enclosing interface:
Poly
A non-zero term of a polynomial.
A term is a pair of a coefficient \( c \neq 0\) and a degree \( d \geq 0 \), representing \(cx^d\).
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final intThe field for thecoefficientrecord component.private final intThe field for thedegreerecord component. -
Constructor Summary
ConstructorsConstructorDescriptionTerm(int coefficient, int degree) Creates a new term with the given coefficient and degree. -
Method Summary
Modifier and TypeMethodDescriptionintReturns the value of thecoefficientrecord component.intdegree()Returns the value of thedegreerecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
coefficient
private final int coefficientThe field for thecoefficientrecord component. -
degree
private final int degreeThe field for thedegreerecord component.
-
-
Constructor Details
-
Term
public Term(int coefficient, int degree) Creates a new term with the given coefficient and degree.- Parameters:
coefficient- the coefficient of the term.degree- the degree of the term.- Throws:
IllegalArgumentException- if the degree is negative or the coefficient is zero.
-
-
Method Details
-
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. -
coefficient
public int coefficient()Returns the value of thecoefficientrecord component.- Returns:
- the value of the
coefficientrecord component
-
degree
-