summaryrefslogtreecommitdiff
path: root/BJC-Utils2/src/main/java/bjc/utils/ioutils/Prompter.java
blob: eed53aecd2d27c17ddc7e64a37d661bf292e4940 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package bjc.utils.ioutils;

import bjc.utils.ioutils.blocks.TriggeredBlockReader;

import java.io.PrintStream;

/**
 * A runnable for use with {@link TriggeredBlockReader} to prompt the user for
 * input.
 * 
 * @author bjculkin
 *
 */
public final class Prompter implements Runnable {
	private String		promt;
	private PrintStream	printer;

	/**
	 * Create a new prompter using the specified prompt.
	 * 
	 * @param prompt
	 *                The prompt to present.
	 * 
	 * @param output
	 *                The stream to print the prompt on.
	 */
	public Prompter(String prompt, PrintStream output) {
		promt = prompt;

		printer = output;
	}

	/**
	 * Set the prompt this prompter uses.
	 * 
	 * @param prompt
	 *                The prompt this prompter uses.
	 */
	public void setPrompt(String prompt) {
		promt = prompt;
	}

	@Override
	public void run() {
		printer.print(promt);
	}
}