diff --git a/TD3_DEV51_Qualite_Algo/src/main/java/fr/iutfbleau/TD3_DEV51_Qualite_Algo/Controllers/Game.java b/TD3_DEV51_Qualite_Algo/src/main/java/fr/iutfbleau/TD3_DEV51_Qualite_Algo/Controllers/Game.java new file mode 100644 index 0000000..4e626b0 --- /dev/null +++ b/TD3_DEV51_Qualite_Algo/src/main/java/fr/iutfbleau/TD3_DEV51_Qualite_Algo/Controllers/Game.java @@ -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; + } +} \ No newline at end of file