Permalink
Browse files

Renamed Keyboard to more generic term (InputDevice)

  • Loading branch information...
1 parent 6b14d38 commit a6660c30be1bcf479d24f9dcfcefd115941c84f1 @ClausPolanka committed Mar 13, 2012
Showing with 7 additions and 6 deletions.
  1. +7 −6 src/test/unit/java/test/unit/spikes/ReadingFromConsoleTest.java
@@ -19,7 +19,7 @@
public InputProcessor inputProcessor;
@Mock
- public Keyboard keyboard;
+ public InputDevice keyboard;
@Test
public void testOneInputFromKeyBoard() throws Exception {
@@ -60,7 +60,7 @@ public void testThreeInputsFromKeyBoard() throws Exception {
void process(String input);
}
- interface Keyboard {
+ interface InputDevice {
String getInput();
}
@@ -71,17 +71,18 @@ public Application(InputProcessor inputProcessor) {
this.inputProcessor = inputProcessor;
}
- public void readInputFrom(Keyboard keyboard) {
+ public void readInputFrom(InputDevice inputDevice) {
while (true) {
- String input = keyboard.getInput();
+ String input = inputDevice.getInput();
if (input.equals("quit")) {
break;
}
inputProcessor.process(input);
}
}
}
- static class ConsoleKeyboard implements Keyboard {
+
+ static class Keyboard implements InputDevice {
private BufferedReader keyboard = new BufferedReader(new InputStreamReader(System.in));
@Override
public String getInput() {
@@ -101,7 +102,7 @@ public void process(String input) {
System.out.println(input);
}
});
- app.readInputFrom(new ConsoleKeyboard());
+ app.readInputFrom(new Keyboard());
}
}
}

0 comments on commit a6660c3

Please sign in to comment.