-
Notifications
You must be signed in to change notification settings - Fork 48
Expand file tree
/
Copy pathYourPlayer.java
More file actions
52 lines (41 loc) · 1.32 KB
/
YourPlayer.java
File metadata and controls
52 lines (41 loc) · 1.32 KB
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
48
49
50
51
package com.hangman.players;
import com.hangman.Player;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Random;
public class YourPlayer implements Player {
private char guessClue;
private LinkedList<Character> guesses;
private List<Character> latestClue;
public YourPlayer() {
this.guesses = new LinkedList<Character>();
final String commonLetter = "gturdtsake";
for (int i = 0; i < commonLetter.length(); i ++ )
guesses.add(commonLetter.charAt(i));
}
public YourPlayer(LinkedList<Character> guesses) {
this.guesses = new LinkedList<Character>();
for (Character character : guesses) {
this.guesses.add(character);
}
}
public void setGuesses(List<Character> chars) {
this.guesses = new LinkedList<Character>();
for(char guess : chars) {
this.guesses.add(guess);
}
}
public LinkedList<Character> getGuesses() {
return guesses;
}
public char GetGuess(List<Character> clue) {
latestClue = clue;
if (guesses.size() > 0 )
return guesses.pop();
return 0 ;
}
public List<Character> getLatestClue() {
return latestClue;
}
}