1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| public class TestBooleen{
static boolean finComptDrap(boolean[][]tabDrapeau,boolean[][]tabBombes){
boolean egal=false;
for(int i=0;i<tabDrapeau.length;i++)
for(int j=0;j<tabDrapeau[i].length;j++)
if(tabDrapeau[i][j]==tabBombes[i][j])
egal=true;
return egal;
}
static boolean finComptDrap2(boolean[][]tabDrapeau,boolean[][]tabBombes){
boolean egal=false;
int i=0;
int j=0;
while(egal && i<tabDrapeau.length && j<tabDrapeau[i].length ){
egal=tabDrapeau[i][j]==tabBombes[i][j];
i++;
}
return egal;
}
public static void main(String[]args){
boolean[][]tabDrapeau={{true,false,true,false},{true,false,true,false}};
boolean[][]tabBombes={{true,false,true,false},{false,false,false,false}};
boolean[][]tabBombes3={{true,false,true,false},{true,false,true,false}};
System.out.println(finComptDrap(tabDrapeau,tabBombes));
System.out.println(finComptDrap(tabDrapeau,tabBombes3));
System.out.println(finComptDrap2(tabDrapeau,tabBombes));
System.out.println(finComptDrap2(tabDrapeau,tabBombes3));
}
} |
Partager