Controllers #8
9
.idea/TD3_DEV51_Qualite_Algo.iml
generated
Normal file
9
.idea/TD3_DEV51_Qualite_Algo.iml
generated
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
8
TD3_DEV51_Qualite_Algo/.idea/.gitignore
generated
vendored
Normal file
8
TD3_DEV51_Qualite_Algo/.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
14
TD3_DEV51_Qualite_Algo/.idea/misc.xml
generated
Normal file
14
TD3_DEV51_Qualite_Algo/.idea/misc.xml
generated
Normal file
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="MavenProjectsManager">
|
||||
<option name="originalFiles">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/pom.xml" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_23" default="true" project-jdk-name="23" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
@@ -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;
|
||||
}
|
||||
}
|
@@ -0,0 +1,7 @@
|
||||
package fr.iutfbleau.TD3_DEV51_Qualite_Algo;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
|
||||
}
|
||||
}
|
@@ -0,0 +1,20 @@
|
||||
public class Letter{
|
||||
private char letter;
|
||||
private boolean status = false;
|
||||
|
||||
public Letter(char letter){
|
||||
this.letter = letter;
|
||||
}
|
||||
/* Show status */
|
||||
private boolean getStatus(){
|
||||
return status
|
||||
}
|
||||
/* Verify status true, false */
|
||||
private boolean isGood(char c){
|
||||
if( this.letter == c){
|
||||
this.status = true;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
Reference in New Issue
Block a user