forked from menault/TD3_DEV51_Qualite_Algo
Compare commits
1 Commits
Controller
...
ccb68428a8
Author | SHA1 | Date | |
---|---|---|---|
ccb68428a8 |
@@ -1,44 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
Reference in New Issue
Block a user