Class Response
-
Constructor Summary
ConstructorDescriptionConstructs a Response object by calculating the number of correctly matched and misplaced elements between the provided code and guess.Constructs a Response object using the given Tuple2 containing the counts of correct and misplaced elements. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Compares this Response object to the specified object for equality.Returns the Tuple2 object containing the counts of correct and misplaced elements.int
hashCode()
Returns the hash code value for this Response object.toString()
Returns a string representation of the Response object.
-
Constructor Details
-
Response
Constructs a Response object using the given Tuple2 containing the counts of correct and misplaced elements.- Parameters:
response
- a Tuple2 object where: - The first element represents the count of correct matches. - The second element represents the count of misplaced elements.
-
Response
Constructs a Response object by calculating the number of correctly matched and misplaced elements between the provided code and guess.The constructor evaluates the following: - Matches where both the position and color are correct. - Matches where the color is correct but the position is incorrect. The results are stored as a Tuple2 consisting of the count of correct matches and the count of misplaced elements.
- Parameters:
code
- the code to be matched, represented as a sequence of colorsguess
- the guessed code, represented as a sequence of colors
-
-
Method Details
-
getResponse
Returns the Tuple2 object containing the counts of correct and misplaced elements.- Returns:
- a Tuple2 containing two integers: - The first integer represents the count of correct key pegs. - The second integer represents the count of misplaced key pegs.
-
equals
Compares this Response object to the specified object for equality.The method first checks if the two objects reference the same memory location; if so, they are considered equal. Next, it checks if the specified object is null or if its class differs from this Response object's class; if either condition is true, they are not considered equal. Finally, it compares the "response" field of the two Response objects for equality.
-
hashCode
public int hashCode()Returns the hash code value for this Response object.The hash code is computed based on the underlying `response` field, which is a Tuple2 containing the counts of correct and misplaced matches. This ensures that the hash code is consistent with the definition of equality provided in the `equals` method.
-
toString
Returns a string representation of the Response object.The returned string includes the count of correctly placed elements (correct count) and the count of misplaced elements (misplacement count), both extracted from the `response` field, formatted in the following structure:
"correct count: [value] misplacement count: [value]"
-