2 Commits

Author SHA1 Message Date
d05f9594d8 Add: Controllers 2025-10-08 12:12:57 +02:00
905787e83d Add: Models Pendu 2025-10-08 11:48:12 +02:00
5 changed files with 101 additions and 50 deletions

View File

@@ -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;
}
}

View File

@@ -1,17 +1,7 @@
package fr.iutfbleau.TD3_DEV51_Qualite_Algo;
//TIP To <b>Run</b> code, press <shortcut actionId="Run"/> or
// click the <icon src="AllIcons.Actions.Execute"/> icon in the gutter.
public class Main {
public static void main(String[] args) {
//TIP Press <shortcut actionId="ShowIntentionActions"/> with your caret at the highlighted text
// to see how IntelliJ IDEA suggests fixing it.
System.out.printf("Hello and welcome!");
for (int i = 1; i <= 5; i++) {
//TIP Press <shortcut actionId="Debug"/> to start debugging your code. We have set one <icon src="AllIcons.Debugger.Db_set_breakpoint"/> breakpoint
// for you, but you can always add more by pressing <shortcut actionId="ToggleLineBreakpoint"/>.
System.out.println("i = " + i);
}
}
}

View File

@@ -1,30 +1,20 @@
public class Lettre{
private char lettre;
public class Letter{
private char letter;
private boolean status = false;
public Lettre(char lettre){
this.lettre = lettre;
public Letter(char letter){
this.letter = letter;
}
/* Status bool */
/* Show status */
private boolean getStatus(){
return status
}
/* Verify status true, false */
private boolean isGood(char c){
if( this.lettre == c){
if( this.letter == c){
this.status = true;
return true;
}
return false;
}
}

View File

@@ -1,22 +0,0 @@
import java.util.*;
public class Mot {
public String mot;
public Lettre[] chaine;
public Mot(String mot){
this.mot = mot;
for(int i = 0; i< this.mot.length();i++){
this.chaine[i] = Lettre(this.mot.charAt(i))
}
}
}

View File

@@ -0,0 +1,49 @@
import java.util.*;
public class Word {
private String word;
private Letter[] tabLetter;
private String c;
private Word(String word){
this.word = word;
for(int i = 0; i< this.word.length();i++){
this.tabLetter[i] = Letter(this.word.charAt(i))
}
}
/* Lettre dans le mot */
private boolean VerifyLetter(String c){
boolean return_bool = false;
for(Letter letter in this.tabLetter){
if(!letter.getStatus()){
if(letter.isGood(c)){
return_bool = true;
}
}
}
return return_bool;
}
/* Le mot a été deviné */
private boolean IsComplet(){
if(Letter letter : this.tabLetter){
if(!letter.getStatus()){
return false;
}
}
return true;
}
}