-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStartWordle.java
More file actions
53 lines (36 loc) · 1.19 KB
/
StartWordle.java
File metadata and controls
53 lines (36 loc) · 1.19 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
52
53
package wordle_gui;
import java.util.*;
public class StartWordle {
public static void main(String args[]) {
//create
Scanner input = new Scanner(System.in);
//create title
System.out.println("Wordle");
//create string array
String[] words = {"SHAKE", "SHARE", "PANIC", "AMUSE", "SHADE"};
int randomNum = (int) Math.random();
int wIndex = (int) (randomNum * words.length);
// System.out.println(randomNum);
// System.out.println(words.length);
// System.out.println(wIndex);
String correct = words[wIndex];
WordleState state = new WordleState(correct);
DisplayWordle display = new DisplayWordle(state, input);
//create loop to keep track of game (if it's still going)
while(!state.isGameOver()) {
//check if the letters are in the right position
//display layout
display.print();
//checks if the word is 5 letters
display.promptGuess();
}
if(state.didWin()) {
System.out.println("Congrats you won!");
}
else {
System.out.println("Sorry try again, maybe next time!");
System.out.println("This was the right word" + state.getWord());
}
input.close();
}
}