Skip to content
Snippets Groups Projects
Commit cdd0ae83 authored by david's avatar david
Browse files

edition de la potence hangman

parent 88bb1463
No related branches found
No related tags found
2 merge requests!2Tanguy,!1David
...@@ -44,94 +44,96 @@ public class hangman ...@@ -44,94 +44,96 @@ public class hangman
/* /*
Affiche l'etat de la potence en fonction du nombre d'essai. Affiche l'etat de la potence en fonction du nombre d'essai.
*/ */
public static void showHangman(int essai) public static String showHangman(int essai)
{ {
System.out.println("----------"); String pot ="";
pot=pot.concat("----------\n");
switch(essai) switch(essai)
{ {
case 1: case 1:
System.out.println("|/"); pot=pot.concat("|/\n");
for(int i=0;i<6;i++) for(int i=0;i<6;i++)
{ {
System.out.println("|"); pot=pot.concat("|\n");
} }
break; break;
case 2: case 2:
System.out.println("|/ |"); pot=pot.concat("|/ |\n");
for(int i=0;i<6;i++) for(int i=0;i<6;i++)
{ {
System.out.println("|"); pot=pot.concat("|\n");
} }
break; break;
case 3 : case 3 :
System.out.println("|/ |"); pot=pot.concat("|/ |\n");
System.out.println("| (_)"); pot=pot.concat("| (_)\n");
for(int i=0;i<5;i++) for(int i=0;i<5;i++)
{ {
System.out.println("|"); pot=pot.concat("|\n");
} }
break; break;
case 4 : case 4 :
System.out.println("|/ |"); pot=pot.concat("|/ |\n");
System.out.println("| (_)"); pot=pot.concat("| (_)\n");
System.out.println("| |"); pot=pot.concat("| |\n");
for(int i=0;i<4;i++) for(int i=0;i<4;i++)
{ {
System.out.println("|"); pot=pot.concat("|\n");
} }
break; break;
case 5 : case 5 :
System.out.println("|/ |"); pot=pot.concat("|/ |\n");
System.out.println("| (_)"); pot=pot.concat("| (_)\n");
System.out.println("| /|"); pot=pot.concat("| /|\n");
for(int i=0;i<4;i++) for(int i=0;i<4;i++)
{ {
System.out.println("|"); pot=pot.concat("|\n");
} }
break; break;
case 6 : case 6 :
System.out.println("|/ |"); pot=pot.concat("|/ |\n");
System.out.println("| (_)"); pot=pot.concat("| (_)\n");
System.out.println("| /|\\"); pot=pot.concat("| /|\\\n");
for(int i=0;i<4;i++) for(int i=0;i<4;i++)
{ {
System.out.println("|"); pot=pot.concat("|");
} }
break; break;
case 7 : case 7 :
System.out.println("|/ |"); pot=pot.concat("|/ |\n");
System.out.println("| (_)"); pot=pot.concat("| (_)\n");
System.out.println("| /|\\"); pot=pot.concat("| /|\\\n");
System.out.println("| | "); pot=pot.concat("| | \n");
for(int i=0;i<3;i++) for(int i=0;i<3;i++)
{ {
System.out.println("|"); pot=pot.concat("|");
} }
break; break;
case 8 : case 8 :
System.out.println("|/ |"); pot=pot.concat("|/ |\n");
System.out.println("| (_)"); pot=pot.concat("| (_)\n");
System.out.println("| /|\\"); pot=pot.concat("| /|\\\n");
System.out.println("| | "); pot=pot.concat("| | \n");
System.out.println("| / "); pot=pot.concat("| / \n");
for(int i=0;i<2;i++) for(int i=0;i<2;i++)
{ {
System.out.println("|"); pot=pot.concat("|");
} }
break; break;
case 9 : case 9 :
System.out.println("|/ |"); pot=pot.concat("|/ |\n");
System.out.println("| (_)"); pot=pot.concat("| (_)\n");
System.out.println("| /|\\"); pot=pot.concat("| /|\\\n");
System.out.println("| | "); pot=pot.concat("| | \n");
System.out.println("| / \\"); pot=pot.concat("| / \\\n");
for(int i=0;i<2;i++) for(int i=0;i<2;i++)
{ {
System.out.println("|"); pot=pot.concat("|\n");
} }
break; break;
} }
System.out.println(""); pot=pot.concat("");
return pot;
} }
} }
\ No newline at end of file
...@@ -24,4 +24,10 @@ class HangmanTests ...@@ -24,4 +24,10 @@ class HangmanTests
hiddenWord=hangman.check(hiddenWord,"david",'d'); hiddenWord=hangman.check(hiddenWord,"david",'d');
assertEquals(hiddenWord,"d___d"); assertEquals(hiddenWord,"d___d");
} }
@Test
void check_potence()
{
String potence =hangman.showHangman(2);
assertEquals(potence,"----------\n|/ |\n|\n|\n|\n|\n|\n|\n");
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment