Class IntegerQuestion
java.lang.Object
com.marcpg.libpg.formular.question.Question
com.marcpg.libpg.formular.question.IntegerQuestion
A question with a number, that can be negative and supports minimum and maximum values.
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
ConstructorDescriptionIntegerQuestion
(String id, String title, String description) Creates a new integer question with no bounds.IntegerQuestion
(String id, String title, String description, int max) Creates a new integer question with minimum value of 0 and a set maximum value.IntegerQuestion
(String id, String title, String description, long min, long max) Creates a new integer question with a minimum and maximum value. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Renders the current question toSystem.out
.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
setInput
(int number) Sets the input, if the question wasn't already submittedvoid
submit()
Submits the question with the current choice and locks in a final answer.void
submit
(int number) Submits the question with a specific input.toResult()
Converts this question to a Result, that can be used in a FormularResult.Methods inherited from class com.marcpg.libpg.formular.question.Question
invalid, isSubmitted, setForm, setRequirement
-
Constructor Details
-
IntegerQuestion
public IntegerQuestion(@Pattern("[a-z0-9_-]+") String id, String title, String description, long min, long max) Creates a new integer question with a minimum and maximum value.- Parameters:
id
- The question's unique identifier.title
- The question's title.description
- The question's description.min
- The minimum value that can be set.max
- The maximum value that can be set.
-
IntegerQuestion
public IntegerQuestion(@Pattern("[a-z0-9_-]+") String id, String title, String description, int max) Creates a new integer question with minimum value of 0 and a set maximum value.- Parameters:
id
- The question's unique identifier.title
- The question's title.description
- The question's description.max
- The maximum value that can be set.
-
IntegerQuestion
Creates a new integer question with no bounds.- Parameters:
id
- The question's unique identifier.title
- The question's title.description
- The question's description.
-
-
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
-
setInput
public void setInput(int number) Sets the input, if the question wasn't already submitted- Parameters:
number
- The new input.
-
submit
public void submit(int number) Submits the question with a specific input.- Parameters:
number
- The input 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.
If there's a min and max choice, it will ask this:Enter a number from -10 to 10:
-