From d05f9594d8898a2e550b40bb66ccf9ff380d0a6b Mon Sep 17 00:00:00 2001 From: bridja Date: Wed, 8 Oct 2025 12:12:57 +0200 Subject: [PATCH] Add: Controllers --- .../Controllers/Game.java | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 TD3_DEV51_Qualite_Algo/src/main/java/fr/iutfbleau/TD3_DEV51_Qualite_Algo/Controllers/Game.java 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 -- 2.51.0