Commit dfe88611 by Josebaezx

Agrego metodo trio

parent 3944d7cf
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="com.android.tools.idea.compose.preview.runconfiguration.ComposePreviewRunConfigurationProducer" />
</set>
</option>
</component>
</project>
\ No newline at end of file
......@@ -31,10 +31,44 @@ public class Juego {
siguiente = false;
System.out.println("COLOR");
}
if (siguiente && trio(cartas)) {
siguiente = false;
System.out.println("TRIO");
}
if (siguiente) {
System.out.println("NADA");
}
}
public boolean trio(List<Carta> cartas) {
List<Integer> valores = new ArrayList<>();
for (Carta c : cartas) {
valores.add(extraer(c.valor));
}
//Collections.sort(valores);
int counter=0;
int numero=0;
int cantidadNumero=0;
for(int i=11; i<14; i++){
for (int j=0; j<valores.size(); j++) {
int s= valores.get(j);
if(s == i){
counter++;
}
}
if(counter > cantidadNumero){
numero=i;
cantidadNumero=counter;
}
counter=0;
}
if (cantidadNumero==3){
return true;
}else {
return false;
}
}
//Dos cartas iguales (mismo valor) junto con tres cartas iguales (mismo valor).
public boolean full(List<Carta> cartas) {
List<Integer> valores = new ArrayList<>();
......
......@@ -9,11 +9,11 @@ public class Main {
List<Carta> cartas = new ArrayList<>();
cartas = Arrays.asList(
new Carta("2H"),
new Carta("2H"),
new Carta("7H"),
new Carta("7S"),
new Carta("7H")
new Carta("QH"),
new Carta("QH"),
new Carta("QH"),
new Carta("5S"),
new Carta("9C")
);
cartas.forEach(System.out::print);
......
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="com.android.tools.idea.compose.preview.runconfiguration.ComposePreviewRunConfigurationProducer" />
</set>
</option>
</component>
</project>
\ No newline at end of file
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