public abstract class ValidatingPrompt extends Object implements Prompt
END_OF_CONVERSATION| Constructor and Description |
|---|
ValidatingPrompt() |
| Modifier and Type | Method and Description |
|---|---|
Prompt |
acceptInput(ConversationContext context,
String input)
Accepts and processes input from the user and validates it.
|
protected abstract Prompt |
acceptValidatedInput(ConversationContext context,
String input)
Override this method to accept and processes the validated input from
the user.
|
boolean |
blocksForInput(ConversationContext context)
Ensures that the prompt waits for the user to provide input.
|
protected String |
getFailedValidationText(ConversationContext context,
String invalidInput)
Optionally override this method to display an additional message if the
user enters an invalid input.
|
protected abstract boolean |
isInputValid(ConversationContext context,
String input)
Override this method to check the validity of the player's input.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetPromptTextpublic Prompt acceptInput(ConversationContext context, String input)
acceptInput in interface Promptcontext - Context information about the conversation.input - The input text from the user.public boolean blocksForInput(ConversationContext context)
blocksForInput in interface Promptcontext - Context information about the conversation.protected abstract boolean isInputValid(ConversationContext context, String input)
context - Context information about the conversation.input - The player's raw console input.protected abstract Prompt acceptValidatedInput(ConversationContext context, String input)
context - Context information about the conversation.input - The validated input text from the user.protected String getFailedValidationText(ConversationContext context, String invalidInput)
context - Context information about the conversation.invalidInput - The invalid input provided by the user.Copyright © 2015. All rights reserved.