Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

prompter

Mircea Anton edited this page Feb 12, 2021 · 1 revision

Prompter

This class encapsulates user interaction in terms of prompting for input in the command line.

Description

This class is built with the Singleton pattern, and as such, only one instance of it can exist at a time in the app. This instance can be accessed via the getInstance() method.

All methods inside this class are self-descriptive and self-documenting.
For example, the getDouble(String prompt) method prints the given prompt to the console and expects a double value to be entered by the user. Similarly, the getBoundedDouble(final String prompt, final double leftBound, final double rightBound) does the same thing, the only difference is that it keeps asking the user for input until a value is entered so that leftBound < value < rightBound.

Clone this wiki locally