Merge remote-tracking branch 'origin/master'

This commit is contained in:
Johann 2019-05-27 20:08:09 +02:00
commit 40d912be16
6 changed files with 122 additions and 22 deletions

View File

@ -71,6 +71,19 @@ Sil ny parvient pas, son roi est alors « échec et mat ». Vous remportez
Pour plus d'informations sur les règles, visitez [ce site](http://www.echecs.club/regles/) ou visitez les [crédits](https://git-iutinfo.unice.fr/good3nought/echesstria#cr%C3%A9dits-revenir-au-sommaire).
### Vous trouverez ici un tableau résumant les pièces :
| Pièce | Lettre |
|:---------:|:--------:|
|Cavalier | C |
|Fou | F |
|Pion | P |
|Reine | Q |
|Roi | K |
|Tour | T |
La lettre ``B`` signifie qu'une pièce est de couleur blanche et la lettre ``N`` signifie qu'une pièce est de couleur noire.
## Crédits [[revenir au sommaire]](https://git-iutinfo.unice.fr/good3nought/echesstria#sommaire)
| Peronne ou Source | Role |
@ -83,7 +96,6 @@ Pour plus d'informations sur les règles, visitez [ce site](http://www.echecs.cl
| |
| [PRITCHARD Adam](https://github.com/adam-p) | [Utilisation](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet) & syntaxe Markdown |
| [http://www.echecs.club](http://www.echecs.club) | [Règles](http://www.echecs.club/regles/) du jeu d'échec |
| |
## License [[revenir au sommaire]](https://git-iutinfo.unice.fr/good3nought/echesstria#sommaire)

1
launch.bat Normal file
View File

@ -0,0 +1 @@
java -jar echesstria.jar

View File

@ -1,5 +1,43 @@
package piecesEchiquier;
//voir equalsIgnoreCase
/*
* Dans cette classes et bien d'autres, nous utilsons la méthode equalsIgnoreCase, voici sa documentation
*
* Compares this {@code String} to another {@code String}, ignoring case
* considerations. Two strings are considered equal ignoring case if they
* are of the same length and corresponding characters in the two strings
* are equal ignoring case.
*
* <p> Two characters {@code c1} and {@code c2} are considered the same
* ignoring case if at least one of the following is true:
* <ul>
* <li> The two characters are the same (as compared by the
* {@code ==} operator)
* <li> Applying the method {@link
* java.lang.Character#toUpperCase(char)} to each character
* produces the same result
* <li> Applying the method {@link
* java.lang.Character#toLowerCase(char)} to each character
* produces the same result
* </ul>
*
* @param anotherString
* The {@code String} to compare this {@code String} against
*
* @return {@code true} if the argument is not {@code null} and it
* represents an equivalent {@code String} ignoring case; {@code
* false} otherwise
*
* @see #equals(Object)
*
* public boolean equalsIgnoreCase(String anotherString) {
* return (this == anotherString) ? true
* : (anotherString != null)
* && (anotherString.value.length == value.length)
* && regionMatches(true, 0, anotherString, 0, value.length);
* }
*/
import joueurs.Joueur;
public class Echiquier {
@ -100,6 +138,13 @@ public class Echiquier {
public boolean verificationMouvement(Joueur J, String A, String B) // FONCTION TRADUCTION, VERIF + DEPLACEMENTS SI POSSIBLE
{// String A = coordonées de A; String B = coordonées de B
/**
* Converts all of the characters in this String to lowercase using the rules of the default locale. This is equivalent to calling toLowerCase(Locale.getDefault()).
* Note: This method is locale sensitive, and may produce unexpectedresults if used for strings that are intended to be interpreted localeindependently.Examples are programming language identifiers, protocol keys, and HTMLtags.For instance, "TITLE".toLowerCase() in a Turkish localereturns "t\u0131tle", where '\u0131' is theLATIN SMALL LETTER DOTLESS I character.To obtain correct results for locale insensitive strings, use toLowerCase(Locale.ROOT).
*
* Ceci est pour forcer le passage en minuscule au cas ou la méthode dans le main ne fonctionne pas
*/
A.toLowerCase();
B.toLowerCase();

View File

@ -27,9 +27,15 @@ public class main {
// déclaration des joueurs
System.out.println("Entrez le nom du joueur 1 : ");
Joueur j1 = new Joueur(sc.nextLine(), null);
if(j1.getNom().isEmpty()) {
j1.setNom("Joueur Par défaut 1");
}
System.out.println("Entrez le nom du joueur 2 : ");
Joueur j2 = new Joueur(sc.nextLine(), null);
if(j2.getNom().isEmpty()) {
j2.setNom("Joueur Par défaut 2");
}
Joueur jTemp = new Joueur(null, null); // ce joueur sert de mémoire pour le choix de l'odre de jeu
@ -83,7 +89,9 @@ public class main {
j1.setCouleur("Noir");
System.out.println("Le joueur " + j2.getNom() + " jouera les blancs et le joueur " + j1.getNom()
+ " jouera les noirs.");
/*
* Alors ici on utilise un joueur temporaire pour faire passe le deuxième joueur en joueur numéro 1
*/
jTemp.setNom(j1.getNom());
jTemp.setCouleur(j1.getCouleur());
@ -145,15 +153,21 @@ public class main {
System.out.println(
"Quelle pièce voulez-vous déplacer ? Donnez le code correspondant de la pièce à déplacer(ex : A1).\n");
A = sc.nextLine();
if(A.isEmpty()) {
A = "Z99";
}
cA = A.charAt(0);
pA = A.charAt(1);
char cAl = Character.toLowerCase(cA);
sA = "" + cAl + pA;
cA = A.charAt(0);//ici on récupère le premier caractère du String
pA = A.charAt(1);//ici on récupère le second caratère
char cAl = Character.toLowerCase(cA); //ici on convertis un 'A' en 'a'
sA = "" + cAl + pA; //ici on concatène dans un nouveau string le a transformé avec le chiffre récupéré.
System.out.println(
"À quel endroit la poser ? Donnez le code correspondant à l'endroit où poser la pièce.\n");
B = sc.nextLine();
if(B.isEmpty()) {
B = "Z99";
}
}while(e.verificationMouvement(j1, sA, B) != true );
@ -208,10 +222,10 @@ public class main {
"Quelle pièce voulez-vous déplacer ? Donnez le code correspondant de la pièce à déplacer(ex : A1).\n");
A = sc.nextLine();
cA = A.charAt(0);
pA = A.charAt(1);
char cAl = Character.toLowerCase(cA);
sA = "" + cAl + pA;
cA = A.charAt(0);//ici on récupère le premier caractère du String
pA = A.charAt(1);//ici on récupère le second caratère
char cAl = Character.toLowerCase(cA); //ici on convertis un 'A' en 'a'
sA = "" + cAl + pA; //ici on concatène dans un nouveau string le a transformé avec le chiffre récupéré.
System.out.println(
"À quel endroit la poser ? Donnez le code correspondant à l'endroit où poser la pièce.\n");
@ -219,8 +233,7 @@ public class main {
}while(e.verificationMouvement(j2, sA, B) != true );
}
} // Tant que le mouvement n'est pas faisable on demande 2 coordonnées
// VERIF ECHECMAT

View File

@ -7,6 +7,20 @@ import org.junit.jupiter.api.Test;
import joueurs.Joueur;
import piecesEchiquier.*;
/*
* @AfterEach is used to signal that the annotated method should beexecuted after each @Test, @RepeatedTest, @ParameterizedTest, @TestFactory,and @TestTemplate method in the current test class.
* org.junit.jupiter.api.AfterEach;
*
* @BeforeEach is used to signal that the annotated method should beexecuted before each @Test, @RepeatedTest, @ParameterizedTest, @TestFactory,and @TestTemplate method in the current test class.
* org.junit.jupiter.api.BeforeEach;
*
* @Test is used to signal that the annotated method is a test method.
* @Test methods must not be private or staticand must not return a value.
* @Test methods may optionally declare parameters to beresolved by ParameterResolvers.
* @Test may also be used as a meta-annotation in order to createa custom composed annotation that inherits the semantics of @Test.
* org.junit.jupiter.api.Test;
* */
class testGeneraux {
private Echiquier e;
private Joueur jb;

View File

@ -6,6 +6,21 @@ import org.junit.jupiter.api.Test;
import joueurs.Joueur;
import piecesEchiquier.*;
/*
* @AfterEach is used to signal that the annotated method should beexecuted after each @Test, @RepeatedTest, @ParameterizedTest, @TestFactory,and @TestTemplate method in the current test class.
* org.junit.jupiter.api.AfterEach;
*
* @BeforeEach is used to signal that the annotated method should beexecuted before each @Test, @RepeatedTest, @ParameterizedTest, @TestFactory,and @TestTemplate method in the current test class.
* org.junit.jupiter.api.BeforeEach;
*
* @Test is used to signal that the annotated method is a test method.
* @Test methods must not be private or staticand must not return a value.
* @Test methods may optionally declare parameters to beresolved by ParameterResolvers.
* @Test may also be used as a meta-annotation in order to createa custom composed annotation that inherits the semantics of @Test.
* org.junit.jupiter.api.Test;
* */
class testPiece {
private Echiquier e;
private Joueur jb;