Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user