Class Prompt
java.lang.Object
Prompt
Prompt.java - Uses BufferedReader.
Provides utilities for user input. This enhances the BufferedReader
class so our programs can recover from "bad" input, and also provides
a way to limit numerical input to a range of values.
The advantages of BufferedReader are speed, synchronization, and piping
data in Linux.
- Since:
- September 1, 2026
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic charPrompts the user for a character and returns the character.static doublePrompts the user for a double and returns the double.static doublePrompts the user for a double and returns the double.static intPrompts the user for an integer and returns the integer.static intPrompts the user for an integer using a range of min to max, and returns the integer.static StringPrompts user for string of characters and returns the string.
-
Constructor Details
-
Prompt
public Prompt()
-
-
Method Details
-
getString
Prompts user for string of characters and returns the string.- Parameters:
ask- The prompt line- Returns:
- The string input
-
getChar
Prompts the user for a character and returns the character.- Parameters:
ask- The prompt line- Returns:
- The character input
-
getInt
Prompts the user for an integer and returns the integer.- Parameters:
ask- The prompt line- Returns:
- The integer input
-
getInt
Prompts the user for an integer using a range of min to max, and returns the integer.- Parameters:
ask- The prompt linemin- The minimum integer acceptedmax- The maximum integer accepted- Returns:
- The integer input
-
getDouble
Prompts the user for a double and returns the double.- Parameters:
ask- The prompt line- Returns:
- The double input
-
getDouble
Prompts the user for a double and returns the double.- Parameters:
ask- The prompt linemin- The minimum double acceptedmax- The maximum double accepted- Returns:
- The double input
-