-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enhancement(lint): Fix lint errors for projects/wordle-gui/Wordle.java
Co-authored-by: NeonGamerBot-QK <[email protected]> Signed-off-by: zeon-neon[bot] <136533918+zeon-neon[bot]@users.noreply.github.com>
- Loading branch information
1 parent
8a41435
commit d716501
Showing
1 changed file
with
58 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,62 @@ | ||
|
||
public class Wordle { | ||
|
||
private String[] words = WordleDictionary.WORDS; | ||
private int[] result = new int[5]; | ||
private static int tries = 0; | ||
private int index = 0; | ||
private String word; | ||
|
||
|
||
public Wordle() { | ||
//get a random word from the list | ||
word = "hoops"; | ||
|
||
/* ***Delete this after you write checkGuess *** */ | ||
result[0] = 2; | ||
result[1] = 2; | ||
result[2] = 2; | ||
result[3] = 2; | ||
result[4] = 2; | ||
/* ********************************************* */ | ||
|
||
} | ||
|
||
public boolean checkIfWord(String guess) { | ||
//return true if the guess is a word | ||
//otherwise return false | ||
|
||
return (guess == null ? word == null : guess.equals(word)); | ||
} | ||
|
||
public String[] getWords() { | ||
return words; | ||
private String[] words = WordleDictionary.WORDS; | ||
private int[] result = new int[5]; | ||
private static int tries = 0; | ||
private int index = 0; | ||
private String word; | ||
|
||
public Wordle() { | ||
//get a random word from the list | ||
word = "hoops"; | ||
|
||
/* ***Delete this after you write checkGuess *** */ | ||
result[0] = 2; | ||
result[1] = 2; | ||
result[2] = 2; | ||
result[3] = 2; | ||
result[4] = 2; | ||
/* ********************************************* */ | ||
|
||
} | ||
|
||
public boolean checkIfWord(String guess) { | ||
//return true if the guess is a word | ||
//otherwise return false | ||
|
||
return (guess == null ? word == null : guess.equals(word)); | ||
} | ||
|
||
public String[] getWords() { | ||
return words; | ||
} | ||
|
||
public String getWord() { | ||
return word; | ||
} | ||
|
||
public int[] getGuess(String guess) { | ||
//updates then returns result | ||
tries++; | ||
result = checkCorrect(guess); | ||
return result; | ||
} | ||
|
||
public int[] checkCorrect(String guess) { | ||
//returns a list of numbers that represent right or wrong | ||
for (int i = 0; i < 5; i++) { | ||
if (word.charAt(i) == guess.charAt(i)) { | ||
result[i] = 1; | ||
} else if (word.indexOf(guess.charAt(i)) >= 0) { | ||
result[i] = 0; | ||
} else { | ||
result[i] = 2; | ||
} | ||
} | ||
return result; | ||
} | ||
|
||
public String getWord() { | ||
return word; | ||
} | ||
|
||
public int[] getGuess(String guess) { | ||
//updates then returns result | ||
tries++; | ||
result = checkCorrect(guess); | ||
return result; | ||
} | ||
|
||
public int[] checkCorrect(String guess) { | ||
//returns a list of numbers that represent right or wrong | ||
for(int i = 0; i < 5;i++) { | ||
if(word.charAt(i) == guess.charAt(i)) { | ||
result[i] = 1; | ||
} else if (word.indexOf(guess.charAt(i)) >= 0) { | ||
result[i] = 0; | ||
} else { | ||
result[i] = 2; | ||
} | ||
} | ||
return result; | ||
} | ||
|
||
|
||
public static int returnTries() { | ||
return tries; | ||
} | ||
} | ||
public static int returnTries() { | ||
return tries; | ||
} | ||
} |