From a4c046c38cfd59e19961aabdb11c520deee1e400 Mon Sep 17 00:00:00 2001 From: JoseBaezx Date: Sat, 23 Apr 2022 09:37:24 -0400 Subject: [PATCH] Se crea metodo para verificar numeros --- .idea/uiDesigner.xml | 124 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ .idea/vcs.xml | 6 ++++++ out/production/java-e003-generala.git/Dado.class | Bin 0 -> 1439 bytes out/production/java-e003-generala.git/Generala.class | Bin 0 -> 2185 bytes out/production/java-e003-generala.git/Play.class | Bin 0 -> 1213 bytes src/Dado.java | 37 +++++++++++++++++++++++++++++++++++++ src/Generala.java | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/Play.java | 16 ++++++++++++++++ 8 files changed, 241 insertions(+) create mode 100644 .idea/uiDesigner.xml create mode 100644 .idea/vcs.xml create mode 100644 out/production/java-e003-generala.git/Dado.class create mode 100644 out/production/java-e003-generala.git/Generala.class create mode 100644 out/production/java-e003-generala.git/Play.class create mode 100644 src/Dado.java create mode 100644 src/Play.java diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml new file mode 100644 index 0000000..e96534f --- /dev/null +++ b/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/out/production/java-e003-generala.git/Dado.class b/out/production/java-e003-generala.git/Dado.class new file mode 100644 index 0000000..71f31cb Binary files /dev/null and b/out/production/java-e003-generala.git/Dado.class differ diff --git a/out/production/java-e003-generala.git/Generala.class b/out/production/java-e003-generala.git/Generala.class new file mode 100644 index 0000000..679d811 Binary files /dev/null and b/out/production/java-e003-generala.git/Generala.class differ diff --git a/out/production/java-e003-generala.git/Play.class b/out/production/java-e003-generala.git/Play.class new file mode 100644 index 0000000..cb8d942 Binary files /dev/null and b/out/production/java-e003-generala.git/Play.class differ diff --git a/src/Dado.java b/src/Dado.java new file mode 100644 index 0000000..042bf40 --- /dev/null +++ b/src/Dado.java @@ -0,0 +1,37 @@ +public class Dado { + + String jugada(String dados) { + int numeros= Integer.parseInt(dados); + + for (int i=1; i<6; i++){ + String valor = String.valueOf((11111* i)); + if (valor.equals(dados)) { + return "GENERALA"; + } + } + for (int i=1; i<7; i++){ + String valor = String.valueOf((1111* i)); + for (int j=1; j<7; j++){ + String valorx = valor + j; + if (valorx.equals(dados)) { + return "PÓKER"; + } + } + } + +// for (int i=1; i<6; i++){ +// if (numeros %i==0) { +// return "FULL"; +// } +// } + + for (int i=15; i<21; i++){ + if (numeros %i==0) { + return "ESCALERA"; + } + } + return "NADA"; + } + + +} diff --git a/src/Generala.java b/src/Generala.java index 2a49169..4dd53ea 100644 --- a/src/Generala.java +++ b/src/Generala.java @@ -1,2 +1,60 @@ +import java.io.Console; +import java.util.ArrayList; +import java.util.List; +import java.util.Scanner; +import java.io.File; public class Generala { + // ESTA ES LA FUNCIÓN QUE HAY QUE IMPLEMENTAR +// TAMBIÉN PUEDEN AGREGAR OTRAS FUNCIONES y/o CLASES +// QUE NECESITEN PARA RESOLVER EL EJERCICIO DE LA +// MANERA MÁS ORDENADA POSIBLE + String jugada(String dados) { + if (dados.equals("11111")) { + return "GENERALA"; + } + return "NADA"; + } + // Ustedes pueden ignorar esto + String[] jugadas(String[] losdados) { + + String[] ret = new String[losdados.length]; + int i = 0; + for (String dados : losdados) + { + ret[i] = this.jugada(dados); + i++; + } + return ret; + } + // Ustedes pueden ignorar esto + static String[] processBatch(String fileName) throws Exception { + Scanner sc = new Scanner(new File(fileName)); + List lines = new ArrayList(); + while (sc.hasNextLine()) { + lines.add(sc.nextLine()); + } + return lines.toArray(new String[0]); + } + public static void main(String[] args) throws Exception { + Generala g = new Generala(); + Play p = new Play(); + Dado d= new Dado(); + + /* IGNORAR PORQUE ESTO NO SE VA A EJECUTAR PARA USTEDES */ + if (args.length > 0) { + String[] jugadas = processBatch(args[0]); + String resultados[] = g.jugadas(jugadas); + for(String res : resultados) { + System.out.println(res); + } + return; + } + +// ESTO SI SE EJECUTA PARA USTEDES + System.out.println(g.jugada("11111")); + + //String resultado = p.lanzarDados(); + //System.out.println("resultado = " + resultado); + System.out.println(d.jugada("66665")); + } } diff --git a/src/Play.java b/src/Play.java new file mode 100644 index 0000000..3bc3675 --- /dev/null +++ b/src/Play.java @@ -0,0 +1,16 @@ +public class Play { + String numeros=""; + + public String getNumeros() { + return numeros; + } + + public String lanzarDados(){ + for (int i=0; i<5;i++){ + int numero = (int) Math.floor(Math.random()*6+1); + this.numeros += (String.valueOf(numero)); + } + return this.numeros; + } + +} -- libgit2 0.26.0