[ Foro de Java ]

Cartas con arrays sin POO

07-Dec-2021 23:12
Invitado (Juan cruz )
0 Respuestas

Hola buenas a todos , necesitaria ayuda para hacer un mazo de cartas e ir tomando cartas del mismo sin que estas se repitan ...
La idea es que sea con arrays y sin POO , mi codigo es este pero no me funciona si me podrian ayudar seria exelente ,

String[] mazo = { "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9", "c10", "c11", "c12", "c13", "c14",
"c15", "c16", "c17", "c18", "c19", "c20", "c21", "c22", "c23", "c24", "c25", "c26", "c27", "c28", "c29",
"c30", "c31", "c32", "c33", "c34", "c35", "c36", "c37", "c38", "c39", "c40", "c41", "c42", "c43", "c44",
"c45", "c46", "c47", "c48", "c49", "c50", "c51", "c52" };

Boolean rep[] = new Boolean[52];
int c , tot=0 , jugada ;



for (int j = 0; j <= 51; j++) {
rep[j] = false;
System.out.println("pos " + rep[j]);
}


c=(int)(Math.random() * 52 + 1);
System.out.println(c);

while (rep[c] == true) {
c=(int)(Math.random() * 52 + 1);
}
rep[c] = true ;




(No se puede continuar esta discusión porque tiene más de dos meses de antigüedad. Si tienes dudas parecidas, abre un nuevo hilo.)