Commit 7dcf18ae by Joel Florentin

fixed poker probability

parent bdddb4d5
......@@ -67,56 +67,62 @@ public class Poker{
}
public static boolean esTrio(Carta[] mano) {
int conta = 0;
int conta = 0,max=0;
int i;
for (i = 0; i < mano.length-1; i++) {
if(mano[i].getValor() == mano[i+1].getValor()){
conta++;
}
else{
break;
conta = 0;
}
if(conta>max)max=conta;
}
return (conta)==2;
return (max)==2;
}
public static boolean esDoblePareja(Carta[] mano) {
int conta = 0;
int contb = 0;
int conta = 0,maxa=0;
int contb = 0, maxb=0;
int i;
for (i = 0; i < mano.length-1; i++) {
if(mano[i].getValor() == mano[i+1].getValor()){
conta++;
}
else{
break;
conta = 0;
}
if(conta>maxa)maxa=conta;
if(maxa==1) break;
}
for (i=i+1 ;i < mano.length-1; i++) {
if(mano[i].getValor() == mano[i+1].getValor()){
contb++;
}
else{
break;
contb = 0;
}
if(contb>maxb)maxb=contb;
}
return conta==contb&&conta==1;
return maxa==maxb&&maxb==1;
}
public static boolean esDoble(Carta[] mano) {
int conta = 0;
int conta = 0,max=0;
int i;
for (i = 0; i < mano.length-1; i++) {
if(mano[i].getValor() == mano[i+1].getValor()){
conta++;
}
else{
break;
conta = 0;
}
if(conta>max)max=conta;
}
return (conta)==1;
return (max)==1;
}
public static boolean esColor(Carta[] mano) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment