Skip to content

Commit

Permalink
enhancement(lint): Fix lint errors for projects/wordle-gui/Wordle.java
Browse files Browse the repository at this point in the history
Co-authored-by: NeonGamerBot-QK <[email protected]>
Signed-off-by: zeon-neon[bot] <136533918+zeon-neon[bot]@users.noreply.github.com>
  • Loading branch information
zeon-neon[bot] and NeonGamerBot-QK authored Dec 11, 2024
1 parent 8a41435 commit d716501
Showing 1 changed file with 58 additions and 61 deletions.
119 changes: 58 additions & 61 deletions projects/wordle-gui/Wordle.java
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;
}
}

0 comments on commit d716501

Please sign in to comment.