MCPcopy Create free account
hub / github.com/Berkeley-CS61B/skeleton-sp23 / StringInputDevice

Class StringInputDevice

proj3/byow/InputDemo/StringInputDevice.java:6–24  ·  view source on GitHub ↗

Created by hug.

Source from the content-addressed store, hash-verified

4 * Created by hug.
5 */
6public class StringInputDevice implements InputSource {
7 private String input;
8 private int index;
9
10 public StringInputDevice(String s) {
11 index = 0;
12 input = s;
13 }
14
15 public char getNextKey() {
16 char returnChar = input.charAt(index);
17 index += 1;
18 return returnChar;
19 }
20
21 public boolean possibleNextInput() {
22 return index < input.length();
23 }
24}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected