Class MultipleChoiceQuestion
java.lang.Object
com.marcpg.libpg.formular.question.Question
com.marcpg.libpg.formular.question.MultipleChoiceQuestion
A question with multiple choices. Only one choice can be checked.
Note that most features will require you to manually implement the JNA dependency (>5.14.0)!
Note that most features will require you to manually implement the JNA dependency (>5.14.0)!
- Since:
- 0.0.8
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.marcpg.libpg.formular.question.Question
Question.QuestionException
-
Field Summary
Fields inherited from class com.marcpg.libpg.formular.question.Question
description, form, id, requirement, submitted, title
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Renders the current question toSystem.out
.void
down()
Moves the cursor down one choice, if it's not already at the bottom.getInput()
Gets the current or preferably final input of the question.void
Resets the state of this question to be as if it was just created.void
submit()
Submits the question with the current choice and locks in a final answer.void
submit
(int choice) Submits the question with a specific choice.void
Submits the question with a specific choice.toResult()
Converts this question to a Result, that can be used in a FormularResult.void
up()
Moves the cursor up one choice, if it's not already all the way up.Methods inherited from class com.marcpg.libpg.formular.question.Question
invalid, isSubmitted, setForm, setRequirement
-
Constructor Details
-
MultipleChoiceQuestion
public MultipleChoiceQuestion(@Pattern("[a-z0-9_-]+") String id, String title, String description, List<String> choices) Creates a new multiple-choice question.- Parameters:
id
- The question's unique identifier.title
- The question's title.description
- The question's description.choices
- A list of the choices that can be chosen from.
-
MultipleChoiceQuestion
public MultipleChoiceQuestion(@Pattern("[a-z0-9_-]+") String id, String title, String description, String... choices) Creates a new multiple-choice question.- Parameters:
id
- The question's unique identifier.title
- The question's title.description
- The question's description.choices
- The choices that can be chosen from.
-
-
Method Details
-
resetState
public void resetState()Description copied from class:Question
Resets the state of this question to be as if it was just created. Won't reset the question's settings, but only the already chosen and rendered things.- Specified by:
resetState
in classQuestion
-
up
public void up()Moves the cursor up one choice, if it's not already all the way up. -
down
public void down()Moves the cursor down one choice, if it's not already at the bottom. -
submit
public void submit(int choice) Submits the question with a specific choice.- Parameters:
choice
- The index of the choice to be submitted.
-
submit
Submits the question with a specific choice.- Parameters:
choice
- The choice to be submitted.
-
submit
public void submit()Description copied from class:Question
Submits the question with the current choice and locks in a final answer. -
getInput
Description copied from class:Question
Gets the current or preferably final input of the question. -
toResult
Description copied from class:Question
Converts this question to a Result, that can be used in a FormularResult. -
cliRender
public void cliRender()Renders the current question toSystem.out
. Will only work forCLIFormular
s.
Gives the user a list of all choices, which can be navigated using W for up, S for down and Space for toggling.
-