Answer

class Answer(answers: ArrayList<Pair<Int, Int>>)

Represents a user's response to an interactive element.

This class holds the user's selection, which consists of one or more pairs of an option index and the number of votes assigned to that option. It provides methods to manipulate the user's answer.

Parameters

answers

The list of answers, where each pair represents an option index and its vote count.

Constructors

Link copied to clipboard
constructor(answers: ArrayList<Pair<Int, Int>>)
constructor(answer: Pair<Int, Int>)

Convenience constructor for creating an answer with a single option and one vote.

Properties

Link copied to clipboard

The list of selected option indices.

Link copied to clipboard
val votes: List<Int>

The list of votes corresponding to each selected option.

Functions

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
fun remove(option: Int)

Removes a selected option from the answer.

Link copied to clipboard
fun set(answer: Pair<Int, Int>)

Sets or updates the vote count for a specific option.

fun set(option: Int, value: Int)

Sets or updates the vote count for a specific option. If the option has already been selected, its vote count will be updated. Otherwise, it will be added to the answer.

Link copied to clipboard
open override fun toString(): String

Stringify user answer data