forked from periodic/Java-Calculator
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPrompt.java
More file actions
44 lines (33 loc) · 885 Bytes
/
Copy pathPrompt.java
File metadata and controls
44 lines (33 loc) · 885 Bytes
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
import java.io.*;
class Prompt {
BufferedReader in;
PrintStream out;
public Prompt(InputStream in, PrintStream out) {
this.in = new BufferedReader(new InputStreamReader(in));
this.out = out;
}
public String getLine() throws IOException {
String st = in.readLine();
return st;
}
public String promptLine() throws IOException {
drawPrompt();
return getLine();
}
private void drawPrompt() {
out.print(">> ");
}
public static void main (String [] args)
{
Prompt prompt = new Prompt(System.in, System.out);
try {
String st = prompt.promptLine();
System.out.println(st);
}
catch (IOException e)
{
System.out.println("IO error.");
System.out.println(e);
}
}
}