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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
public void moveJoker()
{
//int pile[]= {1,2,3,4,5,7,-1,40,21,19,-2,25,51,3};
int pile[]= {1,3,4,5,7,-1,-2};
int joker_A=-1;
int joker_B=-2;
boolean jokerFound=false,foundA=false,foundB=false;
int temp;
for(int i=0;i<pile.length-1 || (!foundA && !foundB);i++)
{
if(!foundA && joker_A==pile[i])
{
temp=pile[i];
pile[i]=pile[i+1];
pile[i+1]=temp;
foundA=true;
}
if(foundA && !foundB && joker_B==pile[i])
{
temp=pile[i];
if(i<pile.length-2)
{
pile[i]=pile[i+2];
pile[i+2]=temp;
}
else
{
if(pile.length<2)
System.out.println("ERREUR PILE TROP PETITE");
else
{
decalB(pile);
}
}
foundB=true;
}
}
for(int i=0;i<pile.length;i++)
System.out.println(pile[i]);
}
public void decalB(int tab[])
{
int temp;
for(int j=tab.length-2;j>1;j--)
{
temp=tab[j];
tab[j]=tab[j-1];
tab[j-1]=temp;
}
} |
Partager