forked from 8thlight/HangmanJava
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConsoleDisplay.java
More file actions
39 lines (29 loc) · 809 Bytes
/
ConsoleDisplay.java
File metadata and controls
39 lines (29 loc) · 809 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
package com.hangman;
import java.util.Observable;
import java.util.Observer;
class ConsoleDisplay implements GameOverDisplay, Observer {
private Writer writer;
ConsoleDisplay() {
this(new ConsoleWriter());
}
ConsoleDisplay(Writer writer) {
this.writer = writer;
}
@Override
public void gameOver() {
writer.writeLine("com.hangman.Game Over");
}
@Override
public void update(Observable o, Object arg) {
Game game = (Game) o;
String clueAsString = "";
for(Character c : game.currentClue()) {
if (c != null) {
clueAsString += c + " ";
} else {
clueAsString += "_ ";
}
}
writer.writeLine("Current Clue Is " + clueAsString);
}
}