Skip to content
Snippets Groups Projects
Commit deb582ff authored by tanguy.dietrich's avatar tanguy.dietrich
Browse files

Ecriture de la fonction print() pour binaryHeap

parent b654219e
No related branches found
No related tags found
2 merge requests!2Tanguy,!1David
This commit is part of merge request !1. Comments created here will be created in the context of that merge request.
package ch.hepia.hangman;
public class hangman
public class Hangman
{
/*
currentWord = l'avancement actuel du mot ex : _a___ == David
......@@ -12,7 +12,7 @@ public class hangman
resultat = _a____
*/
public static String check(String currentWord,String guessWord,char letter)
public static String check(String currentWord,String guessWord,char letter)
{
//les string sont immutable en java
//conversion en tableau de char
......@@ -136,4 +136,4 @@ public class hangman
return pot;
}
}
\ No newline at end of file
}
......@@ -136,9 +136,18 @@ final public class BinaryHeap
public void print()
{
for(int val:lstBinaryHeap)
int index=0;
for(int etage=1;etage<=this.depth();etage++)//e
{
System.out.println(val);
for(int nToShow=0;nToShow<Math.pow(2,etage-1);nToShow++)//n
{
if(index<this.size())
{
System.out.print(" "+this.get(index)+" ");
}
index++;
}
System.out.println("");
}
System.out.println("");
}
......
......@@ -13,21 +13,21 @@ class HangmanTests
@Test
void check_create()
{
String hiddenWord= hangman.createWord("david");
String hiddenWord= Hangman.createWord("david");
assertEquals(hiddenWord,"_____");
}
@Test
void check_test()
{
String hiddenWord= hangman.createWord("david");
hiddenWord=hangman.check(hiddenWord,"david",'d');
void check_test()
{
String hiddenWord= Hangman.createWord("david");
hiddenWord=Hangman.check(hiddenWord,"david",'d');
assertEquals(hiddenWord,"d___d");
}
@Test
void check_potence()
{
String potence =hangman.showHangman(2);
String potence =Hangman.showHangman(2);
assertEquals(potence,"----------\n|/ |\n|\n|\n|\n|\n|\n|\n");
}
}
......@@ -31,9 +31,9 @@ class BinaryHeapTest
bHeap.push(7);lst.add(7);
bHeap.push(40);lst.add(40);
bHeap2.addAll(lst);
//bHeap.print();
bHeap.print();
//bHeap2.print();
//bHeapRand.print();
bHeapRand.print();
assertEquals(bHeap.size(),10);
assertEquals(bHeapRand.size(),20);
assertEquals(bHeapEmpty.isEmpty(),true);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment