diff --git b/Generala/build.xml a/Generala/build.xml new file mode 100644 index 0000000..ff46c3f --- /dev/null +++ a/Generala/build.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + Builds, tests, and runs the project Generala. + + + diff --git b/Generala/manifest.mf a/Generala/manifest.mf new file mode 100644 index 0000000..328e8e5 --- /dev/null +++ a/Generala/manifest.mf @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +X-COMMENT: Main-Class will be added automatically by build + diff --git b/Generala/nbproject/build-impl.xml a/Generala/nbproject/build-impl.xml new file mode 100644 index 0000000..9db2d6c --- /dev/null +++ a/Generala/nbproject/build-impl.xml @@ -0,0 +1,1450 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set platform.home + Must set platform.bootcp + Must set platform.java + Must set platform.javac + + The J2SE Platform is not correctly set up. + Your active platform is: ${platform.active}, but the corresponding property "platforms.${platform.active}.home" is not found in the project's properties files. + Either open the project in the IDE and setup the Platform with the same name or add it manually. + For example like this: + ant -Duser.properties.file=<path_to_property_file> jar (where you put the property "platforms.${platform.active}.home" in a .properties file) + or ant -Dplatforms.${platform.active}.home=<path_to_JDK_home> jar (where no properties file is used) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set src.dir + Must set test.src.dir + Must set build.dir + Must set dist.dir + Must set build.classes.dir + Must set dist.javadoc.dir + Must set build.test.classes.dir + Must set build.test.results.dir + Must set build.classes.excludes + Must set dist.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + No tests executed. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set JVM to use for profiling in profiler.info.jvm + Must set profiler agent JVM arguments in profiler.info.jvmargs.agent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + ${platform.java} -jar "${dist.jar.resolved}" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + Must select one file in the IDE or set run.class + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + Must select one file in the IDE or set debug.class + + + + + Must set fix.includes + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + Must select one file in the IDE or set profile.class + This target only works when run from inside the NetBeans IDE. + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + + + Must select some files in the IDE or set test.includes + + + + + Must select one file in the IDE or set run.class + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + Some tests failed; see details above. + + + + + + + + + Must select some files in the IDE or set test.includes + + + + Some tests failed; see details above. + + + + Must select some files in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + Some tests failed; see details above. + + + + + Must select one file in the IDE or set test.class + + + + Must select one file in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + + + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git b/Generala/nbproject/genfiles.properties a/Generala/nbproject/genfiles.properties new file mode 100644 index 0000000..1f3e017 --- /dev/null +++ a/Generala/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=eb70da8b +build.xml.script.CRC32=152ef490 +build.xml.stylesheet.CRC32=8064a381@1.80.1.48 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=eb70da8b +nbproject/build-impl.xml.script.CRC32=b094bea1 +nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48 diff --git b/Generala/nbproject/private/private.properties a/Generala/nbproject/private/private.properties new file mode 100644 index 0000000..fab0b3a --- /dev/null +++ a/Generala/nbproject/private/private.properties @@ -0,0 +1,2 @@ +compile.on.save=true +user.properties.file=/home/roshka/.netbeans/8.2/build.properties diff --git b/Generala/nbproject/private/private.xml a/Generala/nbproject/private/private.xml new file mode 100644 index 0000000..b497091 --- /dev/null +++ a/Generala/nbproject/private/private.xml @@ -0,0 +1,9 @@ + + + + + + file:/home/roshka/primera-prueba/Generala/src/generala/Generala.java + + + diff --git b/Generala/nbproject/project.properties a/Generala/nbproject/project.properties new file mode 100644 index 0000000..d2297f0 --- /dev/null +++ a/Generala/nbproject/project.properties @@ -0,0 +1,74 @@ +annotation.processing.enabled=true +annotation.processing.enabled.in.editor=false +annotation.processing.processor.options= +annotation.processing.processors.list= +annotation.processing.run.all.processors=true +annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output +build.classes.dir=${build.dir}/classes +build.classes.excludes=**/*.java,**/*.form +# This directory is removed when the project is cleaned: +build.dir=build +build.generated.dir=${build.dir}/generated +build.generated.sources.dir=${build.dir}/generated-sources +# Only compile against the classpath explicitly listed here: +build.sysclasspath=ignore +build.test.classes.dir=${build.dir}/test/classes +build.test.results.dir=${build.dir}/test/results +# Uncomment to specify the preferred debugger connection transport: +#debug.transport=dt_socket +debug.classpath=\ + ${run.classpath} +debug.test.classpath=\ + ${run.test.classpath} +# Files in build.classes.dir which should be excluded from distribution jar +dist.archive.excludes= +# This directory is removed when the project is cleaned: +dist.dir=dist +dist.jar=${dist.dir}/Generala.jar +dist.javadoc.dir=${dist.dir}/javadoc +excludes= +includes=** +jar.compress=false +javac.classpath= +# Space-separated list of extra javac options +javac.compilerargs= +javac.deprecation=false +javac.external.vm=true +javac.processorpath=\ + ${javac.classpath} +javac.source=1.7 +javac.target=1.7 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +javac.test.processorpath=\ + ${javac.test.classpath} +javadoc.additionalparam= +javadoc.author=false +javadoc.encoding=${source.encoding} +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle= +main.class=generala.Generala +manifest.file=manifest.mf +meta.inf.dir=${src.dir}/META-INF +mkdist.disabled=false +platform.active=JDK_1.7 +run.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +# Space-separated list of JVM arguments used when running the project. +# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value. +# To set system properties for unit tests define test-sys-prop.name=value: +run.jvmargs= +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +source.encoding=UTF-8 +src.dir=src +test.src.dir=test diff --git b/Generala/nbproject/project.xml a/Generala/nbproject/project.xml new file mode 100644 index 0000000..d31a8d4 --- /dev/null +++ a/Generala/nbproject/project.xml @@ -0,0 +1,16 @@ + + + org.netbeans.modules.java.j2seproject + + + Generala + + + + + + + + + + diff --git b/Generala/src/generala/Generala.java a/Generala/src/generala/Generala.java new file mode 100644 index 0000000..4a9d815 --- /dev/null +++ a/Generala/src/generala/Generala.java @@ -0,0 +1,123 @@ +package generala; + +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 +class Analizador { + private char[] _texto; + private int _posicion; +private char actual() { + return ver(0); +} +private void continuar() { + _posicion++; + } +private char siguiente() { + return ver(+1); + } +private char ver(int posRelativa) { + return (_posicion + posRelativa) < _texto.length + ? _texto[_posicion + posRelativa] + : '\0'; +} +public String analizar(String texto) { + _texto = texto.toCharArray(); + _posicion = 0; +// poker, full o generala + if (actual() == siguiente()) { + char valor = actual(); + int nroRepeticiones = 0; + while (actual() == valor) { + nroRepeticiones++; + continuar(); + } + if (nroRepeticiones == 5) + return "GENERALA"; + if (nroRepeticiones == 4) + return "POKER"; +// full 3-2 + if (nroRepeticiones == 3) { + valor = actual(); + nroRepeticiones = 0; + while (actual() == valor) { + nroRepeticiones++; + continuar(); + } + return nroRepeticiones == 2 ? "FULL" : "NADA"; + } +// full 2-3 + if (nroRepeticiones == 2) { + valor = actual(); + nroRepeticiones = 0; + while (actual() == valor) { + nroRepeticiones++; + continuar(); + } + return nroRepeticiones == 3 ? "FULL" : "NADA"; + } + } +// escalera + while (_posicion < 4) { + int nroActual = actual() - '0'; + int nroSiguiente = siguiente() - '0'; + if (Math.abs(nroSiguiente - nroActual) != 1 && nroSiguiente != 1) + return "NADA"; + continuar(); + } + return "ESCALERA"; +} +} +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(); +/* 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")); +} +} \ No newline at end of file