diff --git a/README.md b/README.md index c039cf022c822c60e8fd4775a016b2daa47f493f..8099af902a307c40e5e2a60c7054205eb8b4103a 100644 --- a/README.md +++ b/README.md @@ -275,6 +275,44 @@ qui sera une alternative de `Vector.linespace(0.0, 5.0, 20)`. ## Fonctionnalités à réaliser sur le pendu +Modifiez le jeux pour une utilisation suivante : + +```java +Hangman h = HangmanGame.withSecretWord("mystere"); +/* + * variante: Hangman h = HangmanGame.randomWord(); + * (choisit aléatoirement un mot dans une liste) + * doit être implémenté ! + */ + +String currentWord = h.currentWord(); // currentWord = "_______"; +h = h.tryWith('h'); +int attempts = h.attempts(); // attempts = 1 +int failedAttempts = h.failedAttepts(); // attempts = 1 +currentWord = h.currentWord(); // currentWord = "_______"; +h.printGallowsIfError(); // affiche la potence uniquement si le dernier essai est mauvais + +h = h.tryWith('s'); +attempts = h.attempts(); // attempts = 2 +failedAttempts = h.failedAttepts(); // attempts = 1 +currentWord = h.currentWord(); // currentWord = "____e_e"; +h.printGallowsIfError(); +h.printGallows(); // affiche la potence même si aucune erreur + +// Utilisation finale +while ( !h.isFinished() ) { + String letter = askLetter(); // demande une lettre à l'utilisateur + h = h.tryWith( letter ); + h.printCurrentWord(); + h.printGallowIfError(); +} +if( h.hasWon() ) { + System.out.println("Bravo"); +} else { + System.out.println("Failed"); +} +``` + ## Fonctionnalités à réaliser sur les structures