-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathWordsContainer.java
44 lines (31 loc) · 1.11 KB
/
WordsContainer.java
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
package com.kct.fifthsem.cseb.assignment.hangman;
public final class WordsContainer {
private static final Word[] WORDSLISTTOPLAY = {
new Word("apple"), new Word("india"), new Word("laptop"),
new Word("bag"), new Word("charger"), new Word("picture"),
new Word("draw"), new Word("sky"), new Word("box"),
new Word("inch"), new Word("wish"), new Word("subject"),
new Word("catch"), new Word("north"), new Word("eleven"),
new Word("magnet"), new Word("universe"), new Word("philadelphia"),
new Word("shallow"), new Word("shout"), new Word("occasionally")
};
private static final int SIZEOFWORDLIST = WORDSLISTTOPLAY.length;
public static Word wordToPlay()
{
return (generateRandomWordToPlay());
}
private static Word generateRandomWordToPlay()
{
int randomNumber = (int)(Math.random()*SIZEOFWORDLIST);
return WORDSLISTTOPLAY[randomNumber];
}
public static boolean isPlayerPlayedAlltheWords(Player player)
{
if(player!=null
&& player.getNumberofWordsIdentified() == SIZEOFWORDLIST)
{
return true;
}
return false;
}
}