Add: Controllers

This commit is contained in:
2025-10-08 12:12:57 +02:00
parent 905787e83d
commit d05f9594d8

View File

@@ -0,0 +1,44 @@
package Controllers;
import Models.Word;
public class Game {
private Word word;
private int errors;
private final int maxErrors = 6;
public Game(Word word) {
this.word = word;
this.errors = 0;
}
/* Verify error number */
public int getErrors() {
return this.errors;
}
/* Put error max */
public int getMaxErrors() {
return this.maxErrors;
}
/* Vue call method VerifyLetter, check status letter false/True */
public boolean playLetter(char c) {
boolean correct = word.VerifyLetter(c);
if (!correct) {
errors++;
}
return correct;
}
/* All letter is completed : Won */
public boolean isWon() {
return word.IsComplete();
}
/* Lost if maxErrors is greater than or egal to errors */
public boolean isLost() {
return errors >= maxErrors;
}
}