From fca59118e0d4b89604f32aba0de0bafb3c2c6bc6 Mon Sep 17 00:00:00 2001 From: roshka Date: Mon, 8 Oct 2018 14:56:55 -0300 Subject: [PATCH] Programa del tateti --- README.md | 4 ++++ TicTacToe/build.xml | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ TicTacToe/build/classes/.netbeans_automatic_build | 0 TicTacToe/build/classes/.netbeans_update_resources | 0 TicTacToe/build/classes/tictactoe/TicTacToe.class | Bin 0 -> 2669 bytes TicTacToe/manifest.mf | 3 +++ TicTacToe/nbproject/build-impl.xml | 1450 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ TicTacToe/nbproject/genfiles.properties | 8 ++++++++ TicTacToe/nbproject/private/private.properties | 2 ++ TicTacToe/nbproject/private/private.xml | 9 +++++++++ TicTacToe/nbproject/project.properties | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ TicTacToe/nbproject/project.xml | 16 ++++++++++++++++ TicTacToe/src/tictactoe/TicTacToe.java | 128 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 13 files changed, 1767 insertions(+) create mode 100644 README.md create mode 100644 TicTacToe/build.xml create mode 100644 TicTacToe/build/classes/.netbeans_automatic_build create mode 100644 TicTacToe/build/classes/.netbeans_update_resources create mode 100644 TicTacToe/build/classes/tictactoe/TicTacToe.class create mode 100644 TicTacToe/manifest.mf create mode 100644 TicTacToe/nbproject/build-impl.xml create mode 100644 TicTacToe/nbproject/genfiles.properties create mode 100644 TicTacToe/nbproject/private/private.properties create mode 100644 TicTacToe/nbproject/private/private.xml create mode 100644 TicTacToe/nbproject/project.properties create mode 100644 TicTacToe/nbproject/project.xml create mode 100644 TicTacToe/src/tictactoe/TicTacToe.java diff --git a/README.md b/README.md new file mode 100644 index 0000000..87841a5 --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +# TaTeTi +Recomiendo abrir el programa en NetBeans ya que esta hecho en Java. +Al iniciar te va pedir ingresar una coordenada, que seri la posicion de la X u O, estas podrian ser A1, A2.... asi hasta el C3. +Disfruten del juego. \ No newline at end of file diff --git a/TicTacToe/build.xml b/TicTacToe/build.xml new file mode 100644 index 0000000..6fd82dd --- /dev/null +++ b/TicTacToe/build.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + Builds, tests, and runs the project TicTacToe. + + + diff --git a/TicTacToe/build/classes/.netbeans_automatic_build b/TicTacToe/build/classes/.netbeans_automatic_build new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/TicTacToe/build/classes/.netbeans_automatic_build diff --git a/TicTacToe/build/classes/.netbeans_update_resources b/TicTacToe/build/classes/.netbeans_update_resources new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/TicTacToe/build/classes/.netbeans_update_resources diff --git a/TicTacToe/build/classes/tictactoe/TicTacToe.class b/TicTacToe/build/classes/tictactoe/TicTacToe.class new file mode 100644 index 0000000..8ed50df Binary files /dev/null and b/TicTacToe/build/classes/tictactoe/TicTacToe.class differ diff --git a/TicTacToe/manifest.mf b/TicTacToe/manifest.mf new file mode 100644 index 0000000..328e8e5 --- /dev/null +++ b/TicTacToe/manifest.mf @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +X-COMMENT: Main-Class will be added automatically by build + diff --git a/TicTacToe/nbproject/build-impl.xml b/TicTacToe/nbproject/build-impl.xml new file mode 100644 index 0000000..eb6b5f7 --- /dev/null +++ b/TicTacToe/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 a/TicTacToe/nbproject/genfiles.properties b/TicTacToe/nbproject/genfiles.properties new file mode 100644 index 0000000..946daf3 --- /dev/null +++ b/TicTacToe/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=a30aa6c8 +build.xml.script.CRC32=21e49a08 +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=a30aa6c8 +nbproject/build-impl.xml.script.CRC32=e911cc3e +nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48 diff --git a/TicTacToe/nbproject/private/private.properties b/TicTacToe/nbproject/private/private.properties new file mode 100644 index 0000000..fab0b3a --- /dev/null +++ b/TicTacToe/nbproject/private/private.properties @@ -0,0 +1,2 @@ +compile.on.save=true +user.properties.file=/home/roshka/.netbeans/8.2/build.properties diff --git a/TicTacToe/nbproject/private/private.xml b/TicTacToe/nbproject/private/private.xml new file mode 100644 index 0000000..ce369df --- /dev/null +++ b/TicTacToe/nbproject/private/private.xml @@ -0,0 +1,9 @@ + + + + + + file:/home/roshka/primera-prueba/TicTacToe/src/tictactoe/TicTacToe.java + + + diff --git a/TicTacToe/nbproject/project.properties b/TicTacToe/nbproject/project.properties new file mode 100644 index 0000000..430f6a0 --- /dev/null +++ b/TicTacToe/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}/TicTacToe.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=tictactoe.TicTacToe +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 a/TicTacToe/nbproject/project.xml b/TicTacToe/nbproject/project.xml new file mode 100644 index 0000000..abcddfe --- /dev/null +++ b/TicTacToe/nbproject/project.xml @@ -0,0 +1,16 @@ + + + org.netbeans.modules.java.j2seproject + + + TicTacToe + + + + + + + + + + diff --git a/TicTacToe/src/tictactoe/TicTacToe.java b/TicTacToe/src/tictactoe/TicTacToe.java new file mode 100644 index 0000000..8d66aed --- /dev/null +++ b/TicTacToe/src/tictactoe/TicTacToe.java @@ -0,0 +1,128 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package tictactoe; + +import java.util.Scanner; + +/** + * + * @author roshka + */ +public class TicTacToe { + + /** + * @param args the command line arguments + */ + public static void main(String[] args) { + System.out.println("Bienvenido al TA-TE-TI de Fernando del Bootcamp 004 de Roshka"); + + try (Scanner entrada = new Scanner(System.in)) { + int[][] tabla = new int[3][3]; + int i = 0, j = 0; + int jugadorActual = 1; + boolean hayGanador = false; + do { + if (jugadorActual == 1) { + System.out.println(" X -> Ingrese jugada: "); + System.out.print("Siguiente jugada: "); + }else{ + System.out.println(" O -> Ingrese jugada: "); + System.out.print("Siguiente jugada: "); + } + + + + String fc = entrada.nextLine().toUpperCase(); + i = fc.charAt(0) - 'A'; + j = fc.charAt(1) - '1'; + + // Si la celda ya fue marcada por un jugador, anular la jugada + if (tabla[i][j] > 0) { + System.out.println(" ERR: Jugada Inválida - Casilla Ocupada"); + + // Ignora todo el codigo que viene después + // y continua a la siguiente iteración del while + continue; + } + + else { + // Guardar jugador en la celda + tabla[i][j] = jugadorActual; // guardar el numero de jugador + + // Dibujar la tabla para representar la jugada + for (int f = 0; f < tabla.length; f++) { + for (int c = 0; c < tabla.length; c++) { + // Imprimir simbolo según contenido de la celda + switch(tabla[f][c]) { + case 0: System.out.print("-"); break; // vacio + case 1: System.out.print("X"); break; // jugador 1 + case 2: System.out.print("O"); break; // jugador 2 + } + + // Separador de columnas + System.out.print(" | "); + } + + // Separador de filas + System.out.println("\n-----------"); + } + } + + // Chequear si el jugador actual hizo la jugada ganadora + // Diagonal principal + if (tabla[0][0] == jugadorActual && tabla[1][1] == jugadorActual && tabla[2][2] == jugadorActual) { + hayGanador = true; + if (jugadorActual==1) { + System.out.println(" GANADOR X: "+fc); + } + } + + // Diagonal secundaria + else if (tabla[0][2] == jugadorActual && tabla[1][1] == jugadorActual && tabla[2][0] == jugadorActual) { + hayGanador = true; + if (jugadorActual==2) { + System.out.println(" GANADOR O: "+fc); + } + } + + // Rectas + else { + // Chequear en las 3 filas + for (int f = 0; f < tabla.length; f++) { + // Recta horizontal + if (tabla[f][0] == jugadorActual && tabla[f][1] == jugadorActual && tabla[f][2] == jugadorActual) { + hayGanador = true; + if (jugadorActual==1) { + System.out.println(" GANADOR X: "+fc); + }else{ + System.out.println(" GANADOR O: "+fc); + } + + // Salir del for + break; + } + } + + // Chequear en las 3 columnas + for (int c = 0; c < tabla.length; c++) { + // Recta vertical + if (tabla[0][c] == jugadorActual && tabla[1][c] == jugadorActual && tabla[2][c] == jugadorActual) { + hayGanador = true; + System.out.println("GANADOR " + jugadorActual + "!"); + + // Salir del for + break; + } + } + } + + // Pasar el turno al siguiente jugador + // equivalente a if(jugadorActual == 1) jugadorActual = 2; else jugadorActual = 1; + jugadorActual = jugadorActual == 1 ? 2 : 1; + } while (!hayGanador); + } + } +} -- libgit2 0.26.0