├── build.xml ├── build └── classes │ ├── .netbeans_automatic_build │ ├── .netbeans_update_resources │ ├── Collections │ ├── ArrayListSimple.class │ ├── ColeccionArrayList.class │ └── Main.class │ ├── Criptografia │ └── Probador.class │ ├── Interfaces │ ├── Anfibio.class │ ├── Mamifero.class │ ├── Ornitorrinco.class │ ├── Oviparo.class │ ├── Test.class │ └── Venenoso.class │ ├── Serializacion │ ├── Contacto.class │ ├── Persona.class │ ├── PruebaPersona.class │ ├── PruebaSerializadora.class │ └── Serializadora.class │ ├── archivos │ ├── DemostracionDeFile.class │ ├── DemostracionFile.class │ ├── FileList.class │ └── RandomAccessFileDemo.class │ ├── certification │ ├── Fecha.class │ ├── Point2D.class │ ├── Prueba.class │ ├── Pruebas.class │ ├── StrEqual.class │ └── _$CalculoMoneda.class │ ├── clases │ ├── A.class │ ├── B$C.class │ ├── B$D.class │ ├── B.class │ ├── E.class │ ├── Externa.class │ ├── Lampara$Bombilla.class │ └── Lampara.class │ ├── fechas │ ├── DateFormatExample4.class │ ├── Flight.class │ ├── Matriz.class │ ├── Now.class │ ├── NowString.class │ ├── ParseExample.class │ ├── StyleDemo.class │ └── arreglo.class │ ├── herencia │ ├── A.class │ ├── B.class │ ├── C.class │ ├── Dracula.class │ ├── Fecha.class │ ├── FechaJuliana.class │ ├── Ppal.class │ ├── Test.class │ └── Vampiro.class │ ├── hilos │ ├── EjRunnable.class │ ├── HilosSimples.class │ ├── LineaArchivo.class │ ├── Main.class │ └── Proceso.class │ ├── polimorfismo │ ├── .idea │ │ ├── .gitignore │ │ ├── misc.xml │ │ └── modules.xml │ ├── Animal.class │ ├── Bailarín.class │ ├── Boxeo.class │ ├── Gato.class │ ├── Karate.class │ ├── Merenguero.class │ ├── Peleador.class │ ├── Pelión.class │ ├── Perro.class │ ├── Pollito.class │ ├── Ppal.class │ ├── Salsero.class │ ├── Taekwondo.class │ ├── TestAnimals.class │ ├── TestPeleador.class │ ├── Vaca.class │ └── polimorfismo.iml │ ├── practicas │ ├── Empleado.class │ ├── Lista$1.class │ ├── Lista$2.class │ ├── Lista.class │ ├── Nodo.class │ ├── Practica1$1.class │ ├── Practica1$2.class │ ├── Practica1.class │ └── Practica3.class │ ├── pruebas │ ├── AssertionsExample.class │ ├── PecesEnElRio.class │ ├── Temp_Test.class │ ├── Test.class │ └── _$__$.class │ ├── simuladores │ ├── BankBranch.class │ ├── CreditCardCustomer.class │ ├── Customer.class │ └── Test.class │ ├── streams │ └── Stderr.class │ └── strings │ ├── EjSplit.class │ ├── EjStringBuffer.class │ ├── EjTokenizer.class │ ├── EjemploMatches2.class │ ├── EjemploRegionMatches.class │ ├── EjemploRegionMatches3.class │ ├── EjemploSplit.class │ ├── EjemploToken.class │ ├── EjmploStrings.class │ ├── IndexOf.class │ ├── Split.class │ ├── Split_2.class │ ├── TestCadenas.class │ ├── TokenSImple.class │ ├── Tokenizer.class │ ├── Traductor.class │ ├── Traductor_2.class │ └── _T1.class ├── errores.txt ├── manifest.mf ├── nbproject ├── build-impl.xml ├── genfiles.properties ├── private │ ├── private.properties │ └── private.xml ├── project.properties └── project.xml ├── objetos.dat ├── personas.dat ├── src ├── Collections │ ├── ArrayListSimple.java │ ├── ColeccionArrayList.java │ └── Main.java ├── Criptografia │ └── Probador.java ├── Serializacion │ ├── Contacto.java │ ├── Persona.java │ ├── PruebaPersona.java │ ├── PruebaSerializadora.java │ └── Serializadora.java ├── archivos │ ├── DemostracionFile.java │ ├── FileList.java │ └── RandomAccessFileDemo.java ├── certification │ ├── Fecha.java │ ├── Point2D.java │ ├── Prueba.java │ ├── Pruebas.java │ ├── StrEqual.java │ └── _$CalculoMoneda.java ├── clases │ ├── A.java │ └── Externa.java ├── fechas │ ├── DateFormatExample4.java │ ├── Flight.java │ ├── Matriz.java │ ├── Now.java │ ├── NowString.java │ ├── ParseExample.java │ ├── StyleDemo.java │ └── arreglo.java ├── herencia │ ├── A.java │ ├── B.java │ ├── C.java │ ├── Dracula.java │ ├── Fecha.java │ ├── FechaJuliana.java │ ├── Ppal.java │ ├── Test.java │ └── Vampiro.java ├── hilos │ ├── EjRunnable.java │ ├── HilosSimples.java │ ├── LineaArchivo.java │ ├── Main.java │ └── Proceso.java ├── interfaces │ ├── Anfibio.java │ ├── Mamifero.java │ ├── Ornitorrinco.java │ ├── Oviparo.java │ ├── Test.java │ └── Venenoso.java ├── polimorfismo │ ├── .idea │ │ ├── .gitignore │ │ ├── misc.xml │ │ └── modules.xml │ ├── Animal.java │ ├── Bailarín.java │ ├── Boxeo.java │ ├── Gato.java │ ├── Karate.java │ ├── Merenguero.java │ ├── Peleador.java │ ├── Pelión.java │ ├── Perro.java │ ├── Pollito.java │ ├── Ppal.java │ ├── Salsero.java │ ├── Taekwondo.java │ ├── TestAnimals.java │ ├── TestPeleador.java │ ├── Vaca.java │ └── polimorfismo.iml ├── practicas │ ├── Empleado.java │ ├── Lista.java │ ├── Nodo.java │ ├── Practica1.java │ └── Practica3.java ├── pruebas │ ├── AssertionsExample.java │ ├── PecesEnElRio.java │ ├── Temp_Test.java │ ├── Test.java │ └── _$__$.java ├── simuladores │ ├── BankBranch.java │ ├── Customer.java │ └── Test.java ├── streams │ └── Stderr.java └── strings │ ├── EjSplit.java │ ├── EjStringBuffer.java │ ├── EjTokenizer.java │ ├── EjemploMatches2.java │ ├── EjemploRegionMatches.java │ ├── EjemploRegionMatches3.java │ ├── EjemploSplit.java │ ├── EjemploToken.java │ ├── EjmploStrings.java │ ├── IndexOf.java │ ├── Split.java │ ├── Split_2.java │ ├── TestCadenas.java │ ├── TokenSImple.java │ ├── Tokenizer.java │ ├── Traductor.java │ ├── Traductor_2.java │ └── _T1.java └── words.txt /build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | Builds, tests, and runs the project Certification. 12 | 13 | 73 | 74 | -------------------------------------------------------------------------------- /build/classes/.netbeans_automatic_build: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/.netbeans_automatic_build -------------------------------------------------------------------------------- /build/classes/.netbeans_update_resources: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/.netbeans_update_resources -------------------------------------------------------------------------------- /build/classes/Collections/ArrayListSimple.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/Collections/ArrayListSimple.class -------------------------------------------------------------------------------- /build/classes/Collections/ColeccionArrayList.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/Collections/ColeccionArrayList.class -------------------------------------------------------------------------------- /build/classes/Collections/Main.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/Collections/Main.class -------------------------------------------------------------------------------- /build/classes/Criptografia/Probador.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/Criptografia/Probador.class -------------------------------------------------------------------------------- /build/classes/Interfaces/Anfibio.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/Interfaces/Anfibio.class -------------------------------------------------------------------------------- /build/classes/Interfaces/Mamifero.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/Interfaces/Mamifero.class -------------------------------------------------------------------------------- /build/classes/Interfaces/Ornitorrinco.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/Interfaces/Ornitorrinco.class -------------------------------------------------------------------------------- /build/classes/Interfaces/Oviparo.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/Interfaces/Oviparo.class -------------------------------------------------------------------------------- /build/classes/Interfaces/Test.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/Interfaces/Test.class -------------------------------------------------------------------------------- /build/classes/Interfaces/Venenoso.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/Interfaces/Venenoso.class -------------------------------------------------------------------------------- /build/classes/Serializacion/Contacto.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/Serializacion/Contacto.class -------------------------------------------------------------------------------- /build/classes/Serializacion/Persona.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/Serializacion/Persona.class -------------------------------------------------------------------------------- /build/classes/Serializacion/PruebaPersona.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/Serializacion/PruebaPersona.class -------------------------------------------------------------------------------- /build/classes/Serializacion/PruebaSerializadora.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/Serializacion/PruebaSerializadora.class -------------------------------------------------------------------------------- /build/classes/Serializacion/Serializadora.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/Serializacion/Serializadora.class -------------------------------------------------------------------------------- /build/classes/archivos/DemostracionDeFile.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/archivos/DemostracionDeFile.class -------------------------------------------------------------------------------- /build/classes/archivos/DemostracionFile.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/archivos/DemostracionFile.class -------------------------------------------------------------------------------- /build/classes/archivos/FileList.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/archivos/FileList.class -------------------------------------------------------------------------------- /build/classes/archivos/RandomAccessFileDemo.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/archivos/RandomAccessFileDemo.class -------------------------------------------------------------------------------- /build/classes/certification/Fecha.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/certification/Fecha.class -------------------------------------------------------------------------------- /build/classes/certification/Point2D.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/certification/Point2D.class -------------------------------------------------------------------------------- /build/classes/certification/Prueba.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/certification/Prueba.class -------------------------------------------------------------------------------- /build/classes/certification/Pruebas.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/certification/Pruebas.class -------------------------------------------------------------------------------- /build/classes/certification/StrEqual.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/certification/StrEqual.class -------------------------------------------------------------------------------- /build/classes/certification/_$CalculoMoneda.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/certification/_$CalculoMoneda.class -------------------------------------------------------------------------------- /build/classes/clases/A.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/clases/A.class -------------------------------------------------------------------------------- /build/classes/clases/B$C.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/clases/B$C.class -------------------------------------------------------------------------------- /build/classes/clases/B$D.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/clases/B$D.class -------------------------------------------------------------------------------- /build/classes/clases/B.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/clases/B.class -------------------------------------------------------------------------------- /build/classes/clases/E.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/clases/E.class -------------------------------------------------------------------------------- /build/classes/clases/Externa.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/clases/Externa.class -------------------------------------------------------------------------------- /build/classes/clases/Lampara$Bombilla.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/clases/Lampara$Bombilla.class -------------------------------------------------------------------------------- /build/classes/clases/Lampara.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/clases/Lampara.class -------------------------------------------------------------------------------- /build/classes/fechas/DateFormatExample4.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/fechas/DateFormatExample4.class -------------------------------------------------------------------------------- /build/classes/fechas/Flight.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/fechas/Flight.class -------------------------------------------------------------------------------- /build/classes/fechas/Matriz.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/fechas/Matriz.class -------------------------------------------------------------------------------- /build/classes/fechas/Now.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/fechas/Now.class -------------------------------------------------------------------------------- /build/classes/fechas/NowString.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/fechas/NowString.class -------------------------------------------------------------------------------- /build/classes/fechas/ParseExample.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/fechas/ParseExample.class -------------------------------------------------------------------------------- /build/classes/fechas/StyleDemo.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/fechas/StyleDemo.class -------------------------------------------------------------------------------- /build/classes/fechas/arreglo.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/fechas/arreglo.class -------------------------------------------------------------------------------- /build/classes/herencia/A.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/herencia/A.class -------------------------------------------------------------------------------- /build/classes/herencia/B.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/herencia/B.class -------------------------------------------------------------------------------- /build/classes/herencia/C.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/herencia/C.class -------------------------------------------------------------------------------- /build/classes/herencia/Dracula.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/herencia/Dracula.class -------------------------------------------------------------------------------- /build/classes/herencia/Fecha.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/herencia/Fecha.class -------------------------------------------------------------------------------- /build/classes/herencia/FechaJuliana.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/herencia/FechaJuliana.class -------------------------------------------------------------------------------- /build/classes/herencia/Ppal.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/herencia/Ppal.class -------------------------------------------------------------------------------- /build/classes/herencia/Test.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/herencia/Test.class -------------------------------------------------------------------------------- /build/classes/herencia/Vampiro.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/herencia/Vampiro.class -------------------------------------------------------------------------------- /build/classes/hilos/EjRunnable.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/hilos/EjRunnable.class -------------------------------------------------------------------------------- /build/classes/hilos/HilosSimples.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/hilos/HilosSimples.class -------------------------------------------------------------------------------- /build/classes/hilos/LineaArchivo.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/hilos/LineaArchivo.class -------------------------------------------------------------------------------- /build/classes/hilos/Main.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/hilos/Main.class -------------------------------------------------------------------------------- /build/classes/hilos/Proceso.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/hilos/Proceso.class -------------------------------------------------------------------------------- /build/classes/polimorfismo/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | # Datasource local storage ignored files 5 | /dataSources/ 6 | /dataSources.local.xml 7 | # Editor-based HTTP Client requests 8 | /httpRequests/ 9 | -------------------------------------------------------------------------------- /build/classes/polimorfismo/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /build/classes/polimorfismo/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /build/classes/polimorfismo/Animal.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/polimorfismo/Animal.class -------------------------------------------------------------------------------- /build/classes/polimorfismo/Bailarín.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/polimorfismo/Bailarín.class -------------------------------------------------------------------------------- /build/classes/polimorfismo/Boxeo.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/polimorfismo/Boxeo.class -------------------------------------------------------------------------------- /build/classes/polimorfismo/Gato.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/polimorfismo/Gato.class -------------------------------------------------------------------------------- /build/classes/polimorfismo/Karate.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/polimorfismo/Karate.class -------------------------------------------------------------------------------- /build/classes/polimorfismo/Merenguero.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/polimorfismo/Merenguero.class -------------------------------------------------------------------------------- /build/classes/polimorfismo/Peleador.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/polimorfismo/Peleador.class -------------------------------------------------------------------------------- /build/classes/polimorfismo/Pelión.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/polimorfismo/Pelión.class -------------------------------------------------------------------------------- /build/classes/polimorfismo/Perro.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/polimorfismo/Perro.class -------------------------------------------------------------------------------- /build/classes/polimorfismo/Pollito.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/polimorfismo/Pollito.class -------------------------------------------------------------------------------- /build/classes/polimorfismo/Ppal.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/polimorfismo/Ppal.class -------------------------------------------------------------------------------- /build/classes/polimorfismo/Salsero.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/polimorfismo/Salsero.class -------------------------------------------------------------------------------- /build/classes/polimorfismo/Taekwondo.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/polimorfismo/Taekwondo.class -------------------------------------------------------------------------------- /build/classes/polimorfismo/TestAnimals.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/polimorfismo/TestAnimals.class -------------------------------------------------------------------------------- /build/classes/polimorfismo/TestPeleador.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/polimorfismo/TestPeleador.class -------------------------------------------------------------------------------- /build/classes/polimorfismo/Vaca.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/polimorfismo/Vaca.class -------------------------------------------------------------------------------- /build/classes/polimorfismo/polimorfismo.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /build/classes/practicas/Empleado.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/practicas/Empleado.class -------------------------------------------------------------------------------- /build/classes/practicas/Lista$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/practicas/Lista$1.class -------------------------------------------------------------------------------- /build/classes/practicas/Lista$2.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/practicas/Lista$2.class -------------------------------------------------------------------------------- /build/classes/practicas/Lista.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/practicas/Lista.class -------------------------------------------------------------------------------- /build/classes/practicas/Nodo.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/practicas/Nodo.class -------------------------------------------------------------------------------- /build/classes/practicas/Practica1$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/practicas/Practica1$1.class -------------------------------------------------------------------------------- /build/classes/practicas/Practica1$2.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/practicas/Practica1$2.class -------------------------------------------------------------------------------- /build/classes/practicas/Practica1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/practicas/Practica1.class -------------------------------------------------------------------------------- /build/classes/practicas/Practica3.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/practicas/Practica3.class -------------------------------------------------------------------------------- /build/classes/pruebas/AssertionsExample.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/pruebas/AssertionsExample.class -------------------------------------------------------------------------------- /build/classes/pruebas/PecesEnElRio.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/pruebas/PecesEnElRio.class -------------------------------------------------------------------------------- /build/classes/pruebas/Temp_Test.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/pruebas/Temp_Test.class -------------------------------------------------------------------------------- /build/classes/pruebas/Test.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/pruebas/Test.class -------------------------------------------------------------------------------- /build/classes/pruebas/_$__$.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/pruebas/_$__$.class -------------------------------------------------------------------------------- /build/classes/simuladores/BankBranch.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/simuladores/BankBranch.class -------------------------------------------------------------------------------- /build/classes/simuladores/CreditCardCustomer.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/simuladores/CreditCardCustomer.class -------------------------------------------------------------------------------- /build/classes/simuladores/Customer.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/simuladores/Customer.class -------------------------------------------------------------------------------- /build/classes/simuladores/Test.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/simuladores/Test.class -------------------------------------------------------------------------------- /build/classes/streams/Stderr.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/streams/Stderr.class -------------------------------------------------------------------------------- /build/classes/strings/EjSplit.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/strings/EjSplit.class -------------------------------------------------------------------------------- /build/classes/strings/EjStringBuffer.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/strings/EjStringBuffer.class -------------------------------------------------------------------------------- /build/classes/strings/EjTokenizer.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/strings/EjTokenizer.class -------------------------------------------------------------------------------- /build/classes/strings/EjemploMatches2.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/strings/EjemploMatches2.class -------------------------------------------------------------------------------- /build/classes/strings/EjemploRegionMatches.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/strings/EjemploRegionMatches.class -------------------------------------------------------------------------------- /build/classes/strings/EjemploRegionMatches3.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/strings/EjemploRegionMatches3.class -------------------------------------------------------------------------------- /build/classes/strings/EjemploSplit.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/strings/EjemploSplit.class -------------------------------------------------------------------------------- /build/classes/strings/EjemploToken.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/strings/EjemploToken.class -------------------------------------------------------------------------------- /build/classes/strings/EjmploStrings.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/strings/EjmploStrings.class -------------------------------------------------------------------------------- /build/classes/strings/IndexOf.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/strings/IndexOf.class -------------------------------------------------------------------------------- /build/classes/strings/Split.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/strings/Split.class -------------------------------------------------------------------------------- /build/classes/strings/Split_2.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/strings/Split_2.class -------------------------------------------------------------------------------- /build/classes/strings/TestCadenas.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/strings/TestCadenas.class -------------------------------------------------------------------------------- /build/classes/strings/TokenSImple.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/strings/TokenSImple.class -------------------------------------------------------------------------------- /build/classes/strings/Tokenizer.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/strings/Tokenizer.class -------------------------------------------------------------------------------- /build/classes/strings/Traductor.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/strings/Traductor.class -------------------------------------------------------------------------------- /build/classes/strings/Traductor_2.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/strings/Traductor_2.class -------------------------------------------------------------------------------- /build/classes/strings/_T1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/build/classes/strings/_T1.class -------------------------------------------------------------------------------- /errores.txt: -------------------------------------------------------------------------------- 1 | Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 5 2 | at streams.Stderr.main(Stderr.java:24) 3 | -------------------------------------------------------------------------------- /manifest.mf: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | X-COMMENT: Main-Class will be added automatically by build 3 | 4 | -------------------------------------------------------------------------------- /nbproject/genfiles.properties: -------------------------------------------------------------------------------- 1 | build.xml.data.CRC32=a86cbded 2 | build.xml.script.CRC32=d0cd8064 3 | build.xml.stylesheet.CRC32=f85dc8f2@1.99.0.48 4 | # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. 5 | # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. 6 | nbproject/build-impl.xml.data.CRC32=a86cbded 7 | nbproject/build-impl.xml.script.CRC32=6473eb69 8 | nbproject/build-impl.xml.stylesheet.CRC32=d549e5cc@1.99.0.48 9 | -------------------------------------------------------------------------------- /nbproject/private/private.properties: -------------------------------------------------------------------------------- 1 | compile.on.save=true 2 | user.properties.file=C:\\Users\\Asus\\AppData\\Roaming\\NetBeans\\12.4\\build.properties 3 | -------------------------------------------------------------------------------- /nbproject/private/private.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /nbproject/project.properties: -------------------------------------------------------------------------------- 1 | annotation.processing.enabled=true 2 | annotation.processing.enabled.in.editor=false 3 | annotation.processing.processor.options= 4 | annotation.processing.processors.list= 5 | annotation.processing.run.all.processors=true 6 | annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output 7 | build.classes.dir=${build.dir}/classes 8 | build.classes.excludes=**/*.java,**/*.form 9 | # This directory is removed when the project is cleaned: 10 | build.dir=build 11 | build.generated.dir=${build.dir}/generated 12 | build.generated.sources.dir=${build.dir}/generated-sources 13 | # Only compile against the classpath explicitly listed here: 14 | build.sysclasspath=ignore 15 | build.test.classes.dir=${build.dir}/test/classes 16 | build.test.results.dir=${build.dir}/test/results 17 | # Uncomment to specify the preferred debugger connection transport: 18 | #debug.transport=dt_socket 19 | debug.classpath=\ 20 | ${run.classpath} 21 | debug.modulepath=\ 22 | ${run.modulepath} 23 | debug.test.classpath=\ 24 | ${run.test.classpath} 25 | debug.test.modulepath=\ 26 | ${run.test.modulepath} 27 | # Files in build.classes.dir which should be excluded from distribution jar 28 | dist.archive.excludes= 29 | # This directory is removed when the project is cleaned: 30 | dist.dir=dist 31 | dist.jar=${dist.dir}/Certification.jar 32 | dist.javadoc.dir=${dist.dir}/javadoc 33 | excludes= 34 | includes=** 35 | jar.compress=false 36 | javac.classpath= 37 | # Space-separated list of extra javac options 38 | javac.compilerargs= 39 | javac.deprecation=false 40 | javac.modulepath= 41 | javac.processormodulepath= 42 | javac.processorpath=\ 43 | ${javac.classpath} 44 | javac.source=1.7 45 | javac.target=1.7 46 | javac.test.classpath=\ 47 | ${javac.classpath}:\ 48 | ${build.classes.dir} 49 | javac.test.modulepath=\ 50 | ${javac.modulepath} 51 | javac.test.processorpath=\ 52 | ${javac.test.classpath} 53 | javadoc.additionalparam= 54 | javadoc.author=false 55 | javadoc.encoding=${source.encoding} 56 | javadoc.noindex=false 57 | javadoc.nonavbar=false 58 | javadoc.notree=false 59 | javadoc.private=false 60 | javadoc.splitindex=true 61 | javadoc.use=true 62 | javadoc.version=false 63 | javadoc.windowtitle= 64 | main.class=certification.StrEqual 65 | manifest.file=manifest.mf 66 | meta.inf.dir=${src.dir}/META-INF 67 | mkdist.disabled=false 68 | platform.active=default_platform 69 | run.classpath=\ 70 | ${javac.classpath}:\ 71 | ${build.classes.dir} 72 | # Space-separated list of JVM arguments used when running the project. 73 | # You may also define separate properties like run-sys-prop.name=value instead of -Dname=value. 74 | # To set system properties for unit tests define test-sys-prop.name=value: 75 | run.jvmargs= 76 | run.modulepath=\ 77 | ${javac.modulepath} 78 | run.test.classpath=\ 79 | ${javac.test.classpath}:\ 80 | ${build.test.classes.dir} 81 | run.test.modulepath=\ 82 | ${javac.test.modulepath} 83 | source.encoding=UTF-8 84 | src.dir=src 85 | test.src.dir=test 86 | -------------------------------------------------------------------------------- /nbproject/project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | org.netbeans.modules.java.j2seproject 4 | 5 | 6 | Certification 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /objetos.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/objetos.dat -------------------------------------------------------------------------------- /personas.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/personas.dat -------------------------------------------------------------------------------- /src/Collections/ArrayListSimple.java: -------------------------------------------------------------------------------- 1 | package Collections; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Iterator; 5 | public class ArrayListSimple { 6 | public static void main(String[] args) { 7 | ArrayList al = new ArrayList(); 8 | 9 | al.add("Lunes"); 10 | al.add(1, "Martes"); 11 | al.add(2, 3); 12 | 13 | for (Object elemento : al) { 14 | System.out.println(elemento); 15 | } 16 | System.out.println(al.contains("Martes")); 17 | 18 | //al.clear(); 19 | // Obtenemos el numero de elementos del ArrayList 20 | int numElementos = al.size(); 21 | System.out.println("El ArrayList tiene " + numElementos + " elementos"); 22 | 23 | Iterator i = al.iterator(); 24 | while (i.hasNext()) { 25 | Object elemento = i.next(); 26 | if (elemento.equals("Martes")) { 27 | i.remove(); // Eliminamos el Elemento que hemos enocntrado con el Iterator 28 | } 29 | } 30 | 31 | /* while (i.hasNext()) { 32 | Object elemento = i.next(); 33 | System.out.println(i.next()); 34 | 35 | }*/ 36 | for (Object elemento : al) { 37 | System.out.println(elemento); 38 | } 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/Collections/ColeccionArrayList.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Demostración de la colección de genéricos ArrayList 3 | */ 4 | package Collections; 5 | 6 | 7 | import java.util.ArrayList; 8 | 9 | 10 | /** 11 | * @author Alexander Narváez 12 | */ 13 | public class ColeccionArrayList { 14 | 15 | public static void main(String[] args) { 16 | // ArrayList elementos = new ArrayList(); 17 | ArrayList elementos = new ArrayList(); 18 | 19 | elementos.add("Rojo");//adjunta un elemento a la lista 20 | elementos.add(0, "Amarillo");//inserta el valor amarillo en elsubíndice 0 21 | 22 | //encabezado 23 | System.out.print("Mostrar contenido de la lista con ciclo controlado por contador: "); 24 | // se muestran los colores(valores) de la lista 25 | for (int i = 0; i < elementos.size(); i++) { 26 | // System.out.printf("%s", elementos.get(i)); 27 | System.out.println(elementos.get(i)); 28 | } 29 | 30 | // ahora mostraremos los valores usando el foreach en el métdo mostrar() 31 | mostrar(elementos, "\n mostrar elementos de la lista con la instrucción for Mejorada: "); 32 | elementos.add("Verde");//adjunta un elemento a la lista 33 | elementos.add("amarillo");//adjunta el elemento "amarillo" al final de la lista 34 | mostrar(elementos, "Lista con dos nuevo elementos (verde y Amarillo): "); 35 | 36 | elementos.remove("amarillo");//elimina el primer amarillo 37 | mostrar(elementos, "Eliminar la primera coincidencia de amarillo: "); 38 | 39 | elementos.remove(1);// elimina el elemento en l subíndice 1 40 | mostrar(elementos, "Eliminar el segundo elemento de la lista(verde): "); 41 | 42 | //verificar si hay un valor en la lista 43 | System.out.printf("\"rojo\"%s esta en la lista\n", 44 | elementos.contains("rojo") ? "" : "no "); 45 | 46 | //muestra el número de elementos de la lista 47 | System.out.printf("Tamaño: %s\n", elementos.size()); 48 | }//fin del main 49 | 50 | //método que mostrará los elementos del ArrayList en la consola 51 | public static void mostrar(ArrayList elementos, String encabezado) { 52 | 53 | System.out.print(encabezado);//mostrar encabezado 54 | //muestra cada elemento en la lista(elementos) 55 | 56 | for (String elemento : elementos) { 57 | System.out.printf("%s", elemento); 58 | } 59 | System.out.println();//muestra fin de línea 60 | 61 | }//fin del método mostrar 62 | 63 | }//fin de la clase 64 | 65 | -------------------------------------------------------------------------------- /src/Collections/Main.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | 7 | package Collections; 8 | 9 | import java.util.ArrayList; 10 | import java.util.Iterator; 11 | import java.util.LinkedList; 12 | import java.util.List; 13 | 14 | public class Main { 15 | public static void main(String[] args) { 16 | // LinkedList 17 | List lista1 = new LinkedList(); 18 | 19 | // Añadimos nodos y creamos un Iterator 20 | lista1.add("Madrid"); 21 | lista1.add("Sevilla"); 22 | lista1.add("Valencia"); 23 | Iterator iterador = lista1.iterator(); 24 | 25 | // Recorremos y mostramos la lista 26 | while (iterador.hasNext()) { 27 | String elemento = (String) iterador.next(); 28 | System.out.print(elemento + " "); 29 | } 30 | System.out.println("--LinkedList--"); 31 | 32 | // ArrayList 33 | List lista2 = new ArrayList(); 34 | 35 | // Añadimos nodos y creamos un Iterator 36 | lista2.add("Madrid"); 37 | lista2.add("Sevilla"); 38 | lista2.add("Valencia"); 39 | Iterator iterador2 = lista2.iterator(); 40 | 41 | // Recorremos y mostramos la lista 42 | while (iterador2.hasNext()) { 43 | String elemento = (String) iterador2.next(); 44 | System.out.print(elemento + " "); 45 | } 46 | System.out.println("--ArrayList--"); 47 | } 48 | } -------------------------------------------------------------------------------- /src/Criptografia/Probador.java: -------------------------------------------------------------------------------- 1 | 2 | package Criptografia; 3 | 4 | import javax.crypto.Cipher; 5 | import javax.crypto.spec.SecretKeySpec; 6 | /** 7 | * Cifrado/Decifrado con AES y llave simétrica en Java 8 | * Encriptar y desencriptar con AES y llave simétrica. 9 | * En este caso se emplea AES-256, por lo que deberemos tener una clave de largo 32 (32 * 8 = 256). 10 | */ 11 | public class Probador { 12 | 13 | public static void main(String[] args) { 14 | // llaveSimetrica es un String de largo múltiplo de 8 15 | // en este caso si es de largo 32 nos permite AES-256 (32 * 8) 16 | //String llaveSimetrica = "holamundocruel12holamundocruel12"; para usar esta de 32 bytes(256 bits) se necesita 17 | /* librería de criptografía Java no soporta encriptación fuerte (AES > 128). 18 | //to run encryption stronger than 128-bit you will need to download and install 'Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files 6' from http://www.oracle.com/technetwork/java/javase/downloads/index.html. 19 | */ 20 | String llaveSimetrica = "FBkrugerQ!p0W"+"\""+"09"; //16 bytes (128 bits) 21 | 22 | SecretKeySpec key = new SecretKeySpec(llaveSimetrica.getBytes(), "AES"); 23 | Cipher cipher; 24 | try { 25 | cipher = Cipher.getInstance("AES"); 26 | 27 | //Comienzo a encriptar 28 | cipher.init(Cipher.ENCRYPT_MODE, key); 29 | byte[] campoCifrado = cipher.doFinal("mensaje_secreto".getBytes()); 30 | /* 31 | * TODO: Representar los bytes como string vía base64, así será 32 | * humanamente leíble. La otra opción es expresar como hexadecimal 33 | * 34 | * En este caso lo imprimo en pantalla como bytes. 35 | */ 36 | System.out.println(new String(campoCifrado)); 37 | 38 | //Comienzo a desencriptar 39 | cipher.init(Cipher.DECRYPT_MODE, key); 40 | byte[] datosDecifrados = cipher.doFinal(campoCifrado); 41 | String mensaje_original = new String(datosDecifrados); 42 | System.out.println(mensaje_original); 43 | } catch (Exception e) { 44 | e.printStackTrace(); 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /src/Serializacion/Contacto.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Ejemplo de una serialización en java. 3 | * Este programa utiliza 3 clases: Contacto que será la clase serializable 4 | * Serializadora, que será la case de los métodos de streams. 5 | *Y prueba serializadoraque será la clase orquestadora 6 | */ 7 | 8 | package Serializacion; 9 | 10 | /** 11 | * 12 | * @author Alexander NArváez 13 | */ 14 | import java.io.Serializable; 15 | public class Contacto implements Serializable{ 16 | private String nombres; 17 | private String apellidos; 18 | 19 | public String getNombres() { 20 | return nombres; 21 | } 22 | 23 | public void setNombres(String nombres) { 24 | this.nombres = nombres; 25 | } 26 | 27 | public String getApellidos() { 28 | return apellidos; 29 | } 30 | 31 | public void setApellidos(String apellidos) { 32 | this.apellidos = apellidos; 33 | } 34 | 35 | public Contacto(String nombres, String apellidos) { 36 | this.nombres = nombres; 37 | this.apellidos = apellidos; 38 | } 39 | 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/Serializacion/Persona.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Segundo ejemplo de serialización, sólo utiliza 2 clases. 3 | * Persona q es la serializable y PruebaPersona que es laorquestadora de esta 4 | * 5 | */ 6 | package Serializacion; 7 | 8 | /** 9 | * 10 | * @author Alexander Narvaez 11 | */ 12 | import java.io.Serializable; 13 | 14 | public class Persona implements Serializable { 15 | 16 | private int edad; 17 | private String nombre; 18 | private String dni; 19 | 20 | public Persona(int e, String n, String d) { 21 | edad = e; 22 | nombre = n; 23 | dni = d; 24 | 25 | } 26 | 27 | public String toString(){ 28 | 29 | return nombre + ", "+edad+", "+dni; 30 | 31 | } 32 | 33 | public int getEdad() { 34 | return edad; 35 | } 36 | 37 | public void setEdad(int edad) { 38 | this.edad = edad; 39 | } 40 | 41 | public String getNombre() { 42 | return nombre; 43 | } 44 | 45 | public void setNombre(String nombre) { 46 | this.nombre = nombre; 47 | } 48 | 49 | public String getDni() { 50 | return dni; 51 | } 52 | 53 | public void setDni(String dni) { 54 | this.dni = dni; 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /src/Serializacion/PruebaPersona.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Clase que prueba la serialización de la clase Persona 3 | */ 4 | package Serializacion; 5 | 6 | import java.io.BufferedInputStream; 7 | import java.io.BufferedOutputStream; 8 | import java.io.FileInputStream; 9 | import java.io.FileNotFoundException; 10 | import java.io.FileOutputStream; 11 | import java.io.IOException; 12 | import java.io.ObjectInputStream; 13 | import java.io.ObjectOutputStream; 14 | import java.util.Scanner; 15 | 16 | /** 17 | * 18 | * @author Alexander Narváez 19 | */ 20 | public class PruebaPersona { 21 | 22 | public static void main(String[] args) throws FileNotFoundException, IOException, ClassNotFoundException { 23 | Scanner sc = new Scanner(System.in); 24 | System.out.println("Para Serializar digite 1 " 25 | + "Para deserializar digite 2"); 26 | int opcion = sc.nextInt(); 27 | 28 | if (opcion == 1) { 29 | serializar(); 30 | } else { 31 | if (opcion == 2) { 32 | desSerializar(); 33 | } 34 | } 35 | 36 | } 37 | 38 | public static void serializar() throws FileNotFoundException, IOException { 39 | String archivo = "personas.dat"; 40 | BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(archivo)); 41 | ObjectOutputStream oos = new ObjectOutputStream(bos); 42 | 43 | oos.writeObject(new Persona(10, "Pablo", "23.112.223")); 44 | oos.writeObject(new Persona(5, "Sophia", "5.112.223")); 45 | 46 | oos.close(); 47 | bos.close(); 48 | System.out.print("Se ha serializado el objeto con éxito!"); 49 | } 50 | 51 | //una variable no estatica no puede ser referenciada desde un contexto estatico 52 | //por ello los métodos son estaticos y por ello creamos el objeto serio dentro de c/U 53 | static public void desSerializar() throws IOException, ClassNotFoundException { 54 | String archivo = "personas.dat"; 55 | BufferedInputStream bis = new BufferedInputStream(new FileInputStream(archivo)); 56 | ObjectInputStream ois = new ObjectInputStream(bis); 57 | try 58 | { 59 | Persona person = (Persona) ois.readObject(); 60 | 61 | while(true){ 62 | System.out.println(person); 63 | person = (Persona) ois.readObject(); 64 | } 65 | } 66 | catch(IOException ex) 67 | { 68 | System.out.println("-EOF-"); 69 | } 70 | ois.close(); 71 | bis.close(); 72 | 73 | /* System.out.println(person.getEdad()); 74 | System.out.println(person.getNombre()); 75 | System.out.println(person.getDni());*/ 76 | 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/Serializacion/PruebaSerializadora.java: -------------------------------------------------------------------------------- 1 | 2 | package Serializacion; 3 | 4 | import java.io.IOException; 5 | import java.util.logging.Level; 6 | import java.util.logging.Logger; 7 | import java.util.Scanner; 8 | 9 | /** 10 | * 11 | * @author ALexander Narváez 12 | */ 13 | 14 | //import java.io.Serializable;//interfaz serializable 15 | public class PruebaSerializadora { 16 | // Serializadora serio= new Serializadora(); 17 | 18 | public static void Main(String[] args) throws IOException, ClassNotFoundException { 19 | Scanner sc = new Scanner(System.in); 20 | System.out.println("Para Serializar digite 1 " 21 | + "Para deserializar digite 2"); 22 | int opcion = sc.nextInt(); 23 | 24 | if (opcion == 1) { 25 | serializar(); 26 | } else { 27 | if (opcion == 2) { 28 | desSerializar(); 29 | } 30 | } 31 | 32 | } 33 | 34 | public static void serializar() { 35 | Contacto contact = new Contacto("Alexander", "Narváez"); 36 | //Escribimos el objeto 37 | Serializadora serio = new Serializadora(); 38 | serio.escribirObjetos(contact); 39 | System.out.print("Se ha serializado el objeto con éxito!"); 40 | } 41 | //una variable no estatica no puede ser referenciada desde un contexto estatico 42 | //por ello los métodos son estaticos y por ello creamos el objeto serio dentro de c/U 43 | static public void desSerializar() throws IOException, ClassNotFoundException { 44 | Contacto contact = null; 45 | Serializadora serio = new Serializadora(); 46 | contact = (Contacto) serio.LeerObjetos("objetos.dat"); 47 | System.out.println(contact.getNombres()); 48 | System.out.println(contact.getApellidos()); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/Serializacion/Serializadora.java: -------------------------------------------------------------------------------- 1 | package Serializacion; 2 | 3 | /** 4 | * 5 | * @author asus 6 | */ 7 | import java.io.FileInputStream; 8 | import java.io.FileNotFoundException; 9 | import java.io.FileOutputStream; 10 | import java.io.IOException; 11 | 12 | import java.io.ObjectInputStream; 13 | import java.io.ObjectOutputStream; 14 | import java.util.logging.Level; 15 | import java.util.logging.Logger; 16 | 17 | 18 | public class Serializadora { 19 | 20 | private ObjectInputStream lectorDeObjetos; 21 | private ObjectOutputStream escritorDeObjetos; 22 | 23 | public Object LeerObjetos(String nombreDelArchivo) throws IOException, ClassNotFoundException { 24 | Object retorno = null; 25 | 26 | try { 27 | lectorDeObjetos = new ObjectInputStream(new FileInputStream(nombreDelArchivo)); 28 | retorno = lectorDeObjetos.readObject(); 29 | } catch (FileNotFoundException ex) { 30 | Logger.getLogger(Serializadora.class.getName()).log(Level.SEVERE, null, ex); 31 | 32 | } 33 | return retorno; 34 | } 35 | 36 | public void escribirObjetos(Object objeto) { 37 | try { 38 | //Le pasamos como parametro al objeto FileOutPutStream el nombre del archivo donde guardaremos o serializaremos el objeto 39 | escritorDeObjetos = new ObjectOutputStream(new FileOutputStream("objetos.dat")); 40 | escritorDeObjetos.writeObject(objeto); 41 | } catch (IOException ex) { 42 | Logger.getLogger(Serializadora.class.getName()).log(Level.SEVERE, null, ex); 43 | } 44 | 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /src/archivos/DemostracionFile.java: -------------------------------------------------------------------------------- 1 | package archivos; 2 | 3 | import java.io.File; 4 | import java.util.Scanner; 5 | 6 | public class DemostracionFile { 7 | 8 | public static void main(String[] args) { 9 | Scanner entrada = new Scanner(System.in); 10 | 11 | System.out.print("Escriba aqui el nombre del archivo o directorio: "); 12 | analizarRuta(entrada.nextLine()); 13 | } // fin de main 14 | 15 | // muestra información acerca del archivo especificado por el usuario 16 | public static void analizarRuta(String ruta) { 17 | // crea un objeto File con base en la entrada del usuario 18 | File nombre = new File(ruta); 19 | 20 | if (nombre.exists()) // si existe el nombre, muestra información sobre él 21 | { 22 | // muestra información del archivo (o directorio) 23 | System.out.printf( 24 | "%s%s\n%s\n%s\n%s\n%s%s\n%s%s\n%s%s\n%s%s\n%s%s", 25 | nombre.getName(), " existe", 26 | (nombre.isFile() ? "es un archivo" : "no es un archivo"), (nombre.isDirectory() ? "es un directorio" 27 | : "no es un directorio"), 28 | (nombre.isAbsolute() ? "es ruta absoluta" 29 | : "no es ruta absoluta"), "Ultima modificacion: ", 30 | nombre.lastModified(), "Tamanio: ", nombre.length(), 31 | "Ruta: ", nombre.getPath(), "Ruta absoluta: ", 32 | nombre.getAbsolutePath(), "Padre: ", nombre.getParent()); 33 | 34 | if (nombre.isDirectory()) // muestra el listado del directorio 35 | { 36 | String[] directorio = nombre.list(); 37 | System.out.println("\n\nContenido del directorio:\n"); 38 | 39 | for (String nombreDirectorio : directorio) { 40 | System.out.printf("%s\n", nombreDirectorio); 41 | } 42 | } // fin de if 43 | } // fin de if exterior 44 | else // no es archivo o directorio, muestra mensaje de error 45 | { 46 | System.out.printf("%s %s", ruta, "no existe."); 47 | } // fin de else 48 | } // fin del método analizarRuta 49 | } // fin de la clase DemostracionFile 50 | -------------------------------------------------------------------------------- /src/archivos/FileList.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | 7 | package archivos; 8 | 9 | import java.io.File; 10 | 11 | /** 12 | * 13 | * @author asus 14 | */ 15 | public class FileList { 16 | public static void main(String[] args) { 17 | String[] files=new String[100]; 18 | File search = new File("D:"); 19 | files=search.list(); 20 | for(String fn : files) 21 | 22 | System.out.println("Encontrado "+ fn); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/archivos/RandomAccessFileDemo.java: -------------------------------------------------------------------------------- 1 | 2 | 3 | package archivos; 4 | 5 | /** 6 | *The java.io.RandomAccessFile.readLine() method reads the next line of text from this file. 7 | * This method successively reads bytes from the file, starting at the current file pointer, 8 | * until it reaches a line terminator or the end of the file. Each byte is converted into a 9 | * character by taking the byte's value for the lower eight bits of the character and setting 10 | * 11 | * the high eight bits of the character to zero. 12 | */ 13 | import java.io. *; 14 | 15 | public class RandomAccessFileDemo { 16 | 17 | 18 | 19 | public static void main(String[] args) { 20 | try { 21 | // create a new RandomAccessFile with filename test 22 | RandomAccessFile raf = new RandomAccessFile("c:/test.txt", "rw"); 23 | 24 | // write something in the file 25 | raf.writeUTF("Hello World"); 26 | 27 | // set the file pointer at 0 position 28 | raf.seek(0); 29 | 30 | // print the line 31 | System.out.println("" + raf.readLine()); 32 | 33 | // set the file pointer at 0 position 34 | raf.seek(0); 35 | 36 | // write something in the file 37 | raf.writeUTF("This is an example \n Hello World"); 38 | 39 | raf.seek(0); 40 | // print the line 41 | System.out.println("" + raf.readLine()); 42 | } catch (IOException ex) { 43 | ex.printStackTrace(); 44 | } 45 | 46 | } 47 | } -------------------------------------------------------------------------------- /src/certification/Fecha.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package certification; 7 | 8 | /** 9 | * 10 | * @author asus 11 | */ 12 | public class Fecha { 13 | 14 | private int dia; 15 | private int mes; 16 | private int año; 17 | 18 | public void setDia(int dia) { 19 | //establecemos el valor par ala variable día a través del paso de parametro 20 | this.dia = dia;//this hace referencia al atributo dia como variable global a nivel de la clase 21 | // aca el metodo setDia recibe un entero como parametro para el valor del día y luego se lo asigna a la variable global dia 22 | } 23 | 24 | public int getDia() { 25 | //getDia envia el valor del atributo dia declarado como privado a los métodos que deseen consultar dicho valor por fuera de esta clase 26 | return dia; 27 | } 28 | 29 | 30 | public void setMes(int mes){ 31 | this.mes=mes; 32 | 33 | } 34 | 35 | public int getMes(){ 36 | return mes; 37 | } 38 | 39 | public void setAño(int anio){ 40 | this.año=anio; 41 | 42 | } 43 | 44 | public int getAño(){ 45 | return año; 46 | } 47 | 48 | 49 | public String toString(){ 50 | 51 | return dia+"/"+mes+"/"+"año"; 52 | } 53 | 54 | } -------------------------------------------------------------------------------- /src/certification/Point2D.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | 7 | package certification; 8 | 9 | /** 10 | * 11 | * @author asus 12 | */ 13 | public class Point2D { private int x, y; 14 | public Point2D(int x, int y) { 15 | x = x; 16 | } 17 | public String toString() { 18 | return "[" + x + ", " + y + "]"; 19 | } 20 | 21 | public static void main(String []args) { 22 | Point2D point = new Point2D(10, 20); 23 | System.out.println(point); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/certification/Prueba.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | 7 | package certification; 8 | 9 | /** 10 | * 11 | * @author asus 12 | */ 13 | public class Prueba { 14 | 15 | static String nalga; 16 | public static void main(String[] args) { 17 | nalga="nalgota"; 18 | System.out.println(nalga); 19 | } 20 | /* static 21 | { 22 | nalga="nalgota"; 23 | }*/ 24 | } 25 | -------------------------------------------------------------------------------- /src/certification/Pruebas.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | 7 | package certification; 8 | 9 | /** 10 | * 11 | * @author asus 12 | */ 13 | public class Pruebas { 14 | static public void main (String[] args){ 15 | 16 | Fecha f= new Fecha(); 17 | // f.dia=30;// esot no es posible porque el atributo día está declarado como privado en la calse Fecha 18 | f.setDia(30); 19 | System.out.println("Hoy estamos a : "+f.getDia()); 20 | f.setMes(01); 21 | System.out.println("del Mes : "+f.getMes()); 22 | f.setAño(2014); 23 | System.out.println("del Año : "+f.getAño()); 24 | 25 | System.out.println(f.toString()); 26 | 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/certification/StrEqual.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | 7 | package certification; 8 | 9 | /** 10 | * 11 | * @author asus 12 | */ 13 | public class StrEqual { 14 | 15 | /** 16 | * @param args the command line arguments 17 | */ 18 | 19 | public static void main(String []args) { 20 | String s1 = "hi"; 21 | String s2 = new String("hi"); 22 | String s3 = "hi"; 23 | 24 | if(s1 == s2) { 25 | System.out.println("s1 and s2 equal"); 26 | } else { 27 | System.out.println("s1 and s2 not equal"); 28 | } 29 | if(s1 == s3) { 30 | System.out.println("s1 and s3 equal"); 31 | } else { 32 | System.out.println("s1 and s3 not equal"); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/certification/_$CalculoMoneda.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | 7 | package certification; 8 | 9 | /** 10 | * 11 | * @author asus 12 | */ 13 | public class _$CalculoMoneda { 14 | 15 | public static void main(String[] args){ 16 | 17 | float x=new Float(-0.00); 18 | float resultado=(float)Math.sqrt(x); 19 | System.out.println("La raíz cuadrada de " + x + " es " + resultado); 20 | 21 | 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/clases/A.java: -------------------------------------------------------------------------------- 1 | package clases; 2 | 3 | class A { 4 | 5 | private String valora = "A"; 6 | 7 | public void setValora(String valora) { 8 | this.valora = valora; 9 | } 10 | 11 | } 12 | 13 | class B extends A { 14 | 15 | private int edad; 16 | 17 | public int getEdad() { 18 | return edad; 19 | } 20 | 21 | public void setEdad(int edad) { 22 | this.edad = edad; 23 | } 24 | 25 | class C { 26 | 27 | private String valorC = String.valueOf(edad); 28 | 29 | public String getValorC() { 30 | edad = 2; 31 | return valorC; 32 | } 33 | 34 | public void setValorC(String valorC) { 35 | this.valorC = valorC; 36 | } 37 | } 38 | 39 | class D extends C { 40 | } 41 | } 42 | 43 | class E { 44 | 45 | public static void main(String arg[]) { 46 | //creamos un objeto de la clase Externa 47 | B objB = new B(); 48 | //Para crear un objeto de la clase interna utilizamos la instancia 49 | //de la clase externa .(punto) nombre de la clase interna 50 | //Luego el nombre del objeto la palabra new y el Contructor de la Interna 51 | B.C objC = objB.new C(); 52 | //el codigo anterior en una sola linea 53 | B.C objc = new B().new C(); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/clases/Externa.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Programa que muestra el funcionamiento de las clases internas 3 | * Inner Class 4 | * 5 | */ 6 | package clases; 7 | 8 | class Externa { 9 | Lampara miLampara = new Lampara("Globo");// creamos una instancia de la clase Lampara que es una clase externa 10 | Lampara.Bombilla b= miLampara.new Bombilla(125);//con esa instancia creamos otra de la clase Interna: Bombilla 11 | //El código Anterior en una sola Línea: 12 | Lampara.Bombilla b1= new Lampara("Phillips").new Bombilla(100); 13 | //cómo vemos estamos creando una instancia de la clase interna llamada b1 14 | //invocamos el constructor d ela interna luego de invocar el de la externa, ambos constructores reciben parametros 15 | }//fin de la clase Externa 16 | 17 | class Lampara {// clase Externa 18 | 19 | private String forma; 20 | private boolean encendida; 21 | private Bombilla bom;// variable tipo de la clase interna 22 | 23 | public Lampara(String fm) {//Método constructor de la clase externa 24 | forma = fm; 25 | } 26 | 27 | public void cambiarBombilla(int dePot) { 28 | bom = new Bombilla(dePot); 29 | } 30 | 31 | public class Bombilla {// Clase interna 32 | private int potencia; 33 | 34 | public Bombilla(int p) {// Método constructor de la Clase interna 35 | potencia = p; 36 | }//fin del método constructor de la inner class 37 | 38 | }//fin de la Clase Interna 39 | 40 | }//fin de la clase externa(envolvente): Lampara 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /src/fechas/DateFormatExample4.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package fechas; 7 | 8 | /** 9 | * 10 | * @author asus 11 | */ 12 | import java.text.DateFormat; 13 | import java.text.SimpleDateFormat; 14 | import java.text.ParseException; 15 | import java.util.Date; 16 | 17 | public class DateFormatExample4 { 18 | 19 | public static void main(String[] args) { 20 | Date now = new Date(); 21 | String dateString = now.toString(); 22 | System.out.println(" 1. " + dateString); 23 | SimpleDateFormat format = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy"); 24 | System.out.println(" 3. " + format.format(now)); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/fechas/Flight.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package fechas; 7 | 8 | /** 9 | * 10 | * @author asus 11 | */ 12 | import java.util.*; 13 | import java.text.*; 14 | 15 | public class Flight { 16 | 17 | public static void main(String[] args) { 18 | GregorianCalendar finDelMundo = new GregorianCalendar(2012, Calendar.DECEMBER, 21); 19 | Date d = finDelMundo.getTime(); 20 | DateFormat df = DateFormat.getDateInstance(); 21 | String s = df.format(d); 22 | System.out.println("El fin del mundo llegaría el:" + s); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/fechas/Matriz.java: -------------------------------------------------------------------------------- 1 | 2 | 3 | package fechas; 4 | 5 | import java.util.Scanner; 6 | public class Matriz { 7 | public static void main(String[] args) { 8 | 9 | Scanner lector= new Scanner(System.in); 10 | 11 | int m[][]=new int[3][3]; 12 | 13 | int valor =0; 14 | for(int fila =0;fila 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/polimorfismo/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/polimorfismo/Animal.java: -------------------------------------------------------------------------------- 1 | 2 | 3 | package polimorfismo; 4 | 5 | 6 | public abstract class Animal { 7 | 8 | public abstract void expresarse(); 9 | 10 | } 11 | -------------------------------------------------------------------------------- /src/polimorfismo/Bailarín.java: -------------------------------------------------------------------------------- 1 | package polimorfismo; 2 | 3 | abstract public class Bailarín { 4 | 5 | private String nombre; 6 | 7 | public Bailarín(String nombre) { 8 | this.nombre = nombre; 9 | } 10 | 11 | public abstract void bailar(); 12 | 13 | /* public void cantar() { 14 | System.out.println("Presencia y Plata..."); 15 | }*/ 16 | 17 | public String getNombre() { 18 | return nombre; 19 | } 20 | 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/polimorfismo/Boxeo.java: -------------------------------------------------------------------------------- 1 | 2 | package polimorfismo; 3 | 4 | 5 | public class Boxeo extends Peleador { 6 | @Override 7 | public void pelear(){ 8 | 9 | System.out.println("Estoy peleando.. Boxeo " 10 | + "Mis técnicas son: Jab, Upper Cut, Gancho, Cruzado"); 11 | 12 | 13 | } 14 | 15 | void fintear(){} 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/polimorfismo/Gato.java: -------------------------------------------------------------------------------- 1 | 2 | package polimorfismo; 3 | 4 | 5 | public class Gato extends Animal{ 6 | @Override 7 | public void expresarse(){ 8 | System.out.println("Miauu, miauu.."); 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/polimorfismo/Karate.java: -------------------------------------------------------------------------------- 1 | 2 | package polimorfismo; 3 | 4 | public class Karate extends Peleador{ 5 | public void pelear(){ 6 | 7 | System.out.println("Estoy peleando.. Karate " 8 | + "Mis técnicas son: OiZuki, Mawashi Geri, Yoko Geri"); 9 | 10 | 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/polimorfismo/Merenguero.java: -------------------------------------------------------------------------------- 1 | package polimorfismo; 2 | 3 | public class Merenguero extends Bailarín { 4 | 5 | public Merenguero() { 6 | super("Fulanito"); 7 | } 8 | 9 | public void bailar() { 10 | 11 | System.out.println("Sacudelo q' tiene arena, sua, sua, sua..."); 12 | 13 | } 14 | 15 | 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/polimorfismo/Peleador.java: -------------------------------------------------------------------------------- 1 | 2 | package polimorfismo; 3 | 4 | 5 | public abstract class Peleador { 6 | 7 | public void pelear(){ 8 | System.out.println("Peleo a lo borracho"); 9 | } 10 | 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/polimorfismo/Pelión.java: -------------------------------------------------------------------------------- 1 | 2 | package polimorfismo; 3 | 4 | public class Pelión { 5 | Pelión(){ 6 | System.out.println("No soy un estilo, soy todos los estilos .."); 7 | 8 | } 9 | public void pelear(Peleador p){ 10 | 11 | p.pelear(); 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/polimorfismo/Perro.java: -------------------------------------------------------------------------------- 1 | 2 | package polimorfismo; 3 | 4 | public class Perro extends Animal{ 5 | @Override 6 | public void expresarse(){ 7 | System.out.println("Guauu, guauu.."); 8 | } 9 | 10 | } 11 | -------------------------------------------------------------------------------- /src/polimorfismo/Pollito.java: -------------------------------------------------------------------------------- 1 | 2 | package polimorfismo; 3 | 4 | 5 | public class Pollito extends Animal{ 6 | 7 | public void expresarse(){ 8 | System.out.println("pio, pio.."); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/polimorfismo/Ppal.java: -------------------------------------------------------------------------------- 1 | package polimorfismo; 2 | 3 | public class Ppal { 4 | 5 | public static void main(String[] args) { 6 | 7 | Bailarín querubín = new Salsero(); 8 | 9 | querubín.bailar(); 10 | 11 | querubín = new Merenguero(); 12 | querubín.bailar(); 13 | 14 | 15 | 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/polimorfismo/Salsero.java: -------------------------------------------------------------------------------- 1 | package polimorfismo; 2 | 3 | public class Salsero extends Bailarín { 4 | 5 | Salsero(){ 6 | super("Hector La Voe");//invocamos el constructor de la clase base 7 | } 8 | 9 | 10 | public void bailar() {//sobreescribimos el método abstracto bailar 11 | System.out.println("Sonido de las palmeras mi niño..."); 12 | } 13 | 14 | /*public void cantar() {//sobreescribimos el método abstracto cantar 15 | System.out.println(" Asi es que se canta hp.."); 16 | }*/ 17 | } 18 | -------------------------------------------------------------------------------- /src/polimorfismo/Taekwondo.java: -------------------------------------------------------------------------------- 1 | 2 | package polimorfismo; 3 | 4 | 5 | public class Taekwondo extends Peleador{ 6 | public void pelear(){ 7 | 8 | System.out.println("Estoy peleando.. Taekwondo " 9 | + "Mis técnicas son: Pit Chagui, Dollyo Chagui, Mondollyo Furio Chagui, Tuit Chagui"); 10 | 11 | 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/polimorfismo/TestAnimals.java: -------------------------------------------------------------------------------- 1 | 2 | 3 | package polimorfismo; 4 | 5 | public class TestAnimals { 6 | public static void main(String[] args) { 7 | 8 | Animal piolin= new Pollito(); 9 | 10 | piolin.expresarse(); 11 | 12 | piolin = new Vaca(); 13 | 14 | piolin.expresarse(); 15 | 16 | piolin= new Perro(); 17 | piolin.expresarse(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/polimorfismo/TestPeleador.java: -------------------------------------------------------------------------------- 1 | package polimorfismo; 2 | 3 | public class TestPeleador { 4 | 5 | public static void main(String[] args) { 6 | Peleador chuck = new Karate(); 7 | Peleador cook = new Taekwondo(); 8 | Peleador ali = new Boxeo(); 9 | 10 | Boxeo bruce = new Boxeo(); 11 | bruce.pelear();//muestra el del padre, pero se considera ilegal, debería de sobreescribirse o usar sper. 12 | //bruce.fintear(); 13 | Taekwondo bruca = new Taekwondo(); 14 | // Boxeo bruxe = (Boxeo) cook; 15 | // cook.fintear(); 16 | bruce.pelear(); 17 | 18 | Peleador fighter[] = new Peleador[4]; 19 | 20 | fighter[0] = bruce; 21 | fighter[1] = chuck; 22 | fighter[2] = cook; 23 | fighter[3] = ali; 24 | for (int i = 0; i < fighter.length;) { 25 | fighter[i++].pelear(); 26 | } 27 | 28 | Pelión narva = new Pelión(); 29 | narva.pelear(ali); 30 | narva.pelear(chuck); 31 | narva.pelear(cook); 32 | narva.pelear(bruce); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/polimorfismo/Vaca.java: -------------------------------------------------------------------------------- 1 | 2 | package polimorfismo; 3 | 4 | 5 | public class Vaca extends Animal{ 6 | 7 | public void expresarse(){ 8 | System.out.println("MUuuuu.."); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/polimorfismo/polimorfismo.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/practicas/Empleado.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | 7 | package practicas; 8 | 9 | 10 | 11 | public class Empleado { 12 | private String nombre = ""; 13 | 14 | private String apellido = ""; 15 | 16 | private String cedula = ""; 17 | 18 | private String telefono = ""; 19 | 20 | private String salario = ""; 21 | 22 | private String tipoContrato = ""; 23 | 24 | private String estado = ""; 25 | 26 | private boolean valido = true; 27 | 28 | private String queMalo = ""; 29 | 30 | /** 31 | * @return the nombre 32 | */ 33 | public String getNombre() { 34 | return nombre; 35 | } 36 | 37 | /** 38 | * @param nombre the nombre to set 39 | */ 40 | public void setNombre(String nombre) { 41 | this.nombre = nombre; 42 | } 43 | 44 | /** 45 | * @return the apellido 46 | */ 47 | public String getApellido() { 48 | return apellido; 49 | } 50 | 51 | /** 52 | * @param apellido the apellido to set 53 | */ 54 | public void setApellido(String apellido) { 55 | this.apellido = apellido; 56 | } 57 | 58 | /** 59 | * @return the cedula 60 | */ 61 | public String getCedula() { 62 | return cedula; 63 | } 64 | 65 | /** 66 | * @param cedula the cedula to set 67 | */ 68 | public void setCedula(String cedula) { 69 | this.cedula = cedula; 70 | } 71 | 72 | /** 73 | * @return the telefono 74 | */ 75 | public String getTelefono() { 76 | return telefono; 77 | } 78 | 79 | /** 80 | * @param telefono the telefono to set 81 | */ 82 | public void setTelefono(String telefono) { 83 | this.telefono = telefono; 84 | } 85 | 86 | /** 87 | * @return the salario 88 | */ 89 | public String getSalario() { 90 | return salario; 91 | } 92 | 93 | /** 94 | * @param salario the salario to set 95 | */ 96 | public void setSalario(String salario) { 97 | this.salario = salario; 98 | } 99 | 100 | /** 101 | * @return the tipoContrato 102 | */ 103 | public String getTipoContrato() { 104 | return tipoContrato; 105 | } 106 | 107 | /** 108 | * @param tipoContrato the tipoContrato to set 109 | */ 110 | public void setTipoContrato(String tipoContrato) { 111 | this.tipoContrato = tipoContrato; 112 | } 113 | 114 | /** 115 | * @return the estado 116 | */ 117 | public String getEstado() { 118 | return estado; 119 | } 120 | 121 | /** 122 | * @param estado the estado to set 123 | */ 124 | public void setEstado(String estado) { 125 | this.estado = estado; 126 | } 127 | 128 | /** 129 | * @return the valido 130 | */ 131 | public boolean isValido() { 132 | return valido; 133 | } 134 | 135 | /** 136 | * @param valido the valido to set 137 | */ 138 | public void setValido(boolean valido) { 139 | this.valido = valido; 140 | } 141 | 142 | /** 143 | * @return the queMalo 144 | */ 145 | public String getQueMalo() { 146 | return queMalo; 147 | } 148 | 149 | /** 150 | * @param queMalo the queMalo to set 151 | */ 152 | public void setQueMalo(String queMalo) { 153 | this.queMalo = queMalo; 154 | } 155 | 156 | @Override 157 | /*public String toString() { 158 | return String.format("Nombre: %s, Apellido: %s, Cedula: %s, Teléfono: %s, Salario: %s, Tipo Contrato: %s, Estado: %s" + (valido ? "" : " (*) " + queMalo), nombre, 159 | apellido, cedula, telefono, salario, tipoContrato, estado); 160 | }*/ 161 | 162 | public String toString() { 163 | return String.format("Nombre: %s \n Apellido: %s\nCedula: %s\n Teléfono: %s\n Salario: %s\nTipo Contrato: %s\n Estado: %s" + (valido ? "" : " (*) " + queMalo), nombre, 164 | apellido, cedula, telefono, salario, tipoContrato, estado); 165 | 166 | } 167 | } 168 | -------------------------------------------------------------------------------- /src/practicas/Lista.java: -------------------------------------------------------------------------------- 1 | package practicas; 2 | 3 | import java.util.Collections; 4 | import java.util.Comparator; 5 | import java.util.List; 6 | 7 | /** 8 | * Esta clase contendrá los métodos para trabajar con nodos como: insertar, 9 | * eliminar, buscar, etc 10 | * 11 | * @author Alexánder Narváez 12 | */ 13 | public class Lista { 14 | 15 | Nodo inicio;//declaro nodo inicial 16 | Nodo fin;//declaro nodo final 17 | 18 | 19 | private String usuario, res; 20 | //constructor de la clase 21 | public Lista() { 22 | inicio = null; 23 | fin = null; 24 | /*observar que apuntan a null porque cuando se crea una lista solo hay un nodo 25 | despues de ese nodo no hay nada, por ello inicio y in apuntan a null, porque 26 | es el primer bloque, se acaba de crear la lista y sólo hay un elemento 27 | */ 28 | 29 | } 30 | 31 | //Método que insertará un nuevo nodo al inicio de la lista 32 | public void insertarInicio(String info, String info2) { 33 | //Creamos entonces el nodo que irá al inicio 34 | //Observemos que pasamos inicio que es de tipo Nodo como segundo parámetro,es decir para que nuevo apunte al inicio 35 | Nodo nuevo = new Nodo(info, info2,inicio);//info es el primer parámetro es String 36 | 37 | inicio = nuevo;//hacemos una asignación, el nuevo nodo va a ser el inicio de la lista 38 | if (fin == null) {//preguntamos q si el último nodo es igual a null entonces 39 | fin = inicio;//el nodo final sera igual al inicio 40 | } 41 | 42 | } 43 | 44 | //Método que insertará un nueov nodo al fina de la lista 45 | public void insertarFinal(String info, String info2) { 46 | //Creamos entonces el nodo que irá al inicio 47 | //Observemos que pasamos inicio que es de tipo Nodo como segundo parámetro 48 | Nodo nuevo = new Nodo(info,info2, null);//null porq el último nodo tiene que apuntar a null 49 | 50 | if (inicio == null) {//si la lista se acaba de crear, ya q solo es null cuando recien se crea la lista 51 | fin = nuevo;//el nodo final sera igual al nuevo nodo 52 | inicio = fin;// como se acaba de crear la lista los 2 están en el mismo lugar(sólo hay un nodo) 53 | } else {// pero en caso de que la lista ya contenga algunos elementos 54 | fin.setSiguiente(nuevo);//entoces enviamos el nuevo nodo a continuación del fin como gancho de este 55 | fin = nuevo;//el nuevo nodo se ubica al final, fin = nodo; 56 | } 57 | 58 | } 59 | 60 | public void eliminarInicio() { 61 | inicio = inicio.siguiente; 62 | //simplemente con esta instrucción saltamos directo al siguiente nodo ignorando la cabeza 63 | } 64 | 65 | public String extraerInicio() { 66 | String info = inicio.getInfo(); 67 | inicio = inicio.getSiguiente();//esta linea reemplaza inicio con siguiente, es decir lo elimina 68 | if (inicio == null) {//si la lista se acaba de crear 69 | fin = null; 70 | } 71 | return info; 72 | } 73 | 74 | public int encontrarNodo(String buscado) { 75 | boolean encontrado=false; 76 | int c=1; 77 | Nodo temp = inicio;//guardamos el nodo cabecera en temp al iniciara 78 | while (temp != null) {//mientras haya informaicón válida en el nodo 79 | if (temp.getInfo().equals(buscado)) { 80 | System.out.println(" Se ha encontrado " + temp.getInfo()); 81 | encontrado=true; 82 | return c; 83 | } 84 | 85 | temp = temp.siguiente;//avanzamos al siguient enodo y lo cargamos en temp 86 | c++; 87 | } 88 | if (encontrado) 89 | System.out.println("Parcero esa vuelta no se halló en esta lista, mi niño"); 90 | return c; 91 | } 92 | 93 | public int encontrarNodo2(String buscado1, String buscado2) { 94 | boolean encontrado=false; 95 | int c=1; 96 | Nodo temp = inicio;//guardamos el nodo cabecera en temp al iniciara 97 | while (temp != null) {//mientras haya informaicón válida en el nodo 98 | if ((temp.getInfo().equals(buscado1))&& (temp.getInfo2().equals(buscado2))) { 99 | System.out.println(" Se ha encontrado " + temp.getInfo()); 100 | encontrado=true; 101 | return c; 102 | } 103 | 104 | temp = temp.siguiente;//avanzamos al siguient enodo y lo cargamos en temp 105 | c++; 106 | } 107 | if (encontrado) 108 | System.out.println("Parcero esa vuelta no se halló en esta lista, mi niño"); 109 | return c; 110 | } 111 | 112 | 113 | public void validarUsuario(String user, String clave, int intentos) { 114 | // public void validarUsuario(String datos[], String user, String clave, int intentos) { 115 | boolean encontrado = false; 116 | Nodo temp = inicio;//guardamos el nodo cabecera en temp al iniciara 117 | while (temp != null) {//mientras haya informaicón válida en el nodo 118 | if ((temp.getInfo().equals(user)) &&(temp.getInfo2().equals(clave))) { 119 | res = "bienvenido " + user; 120 | javax.swing.JOptionPane.showMessageDialog(null, res); 121 | System.out.println(" Se ha encontrado " + temp.getInfo() + " clave: " + temp.getInfo()); 122 | encontrado = true; 123 | // return c; 124 | } 125 | 126 | temp = temp.siguiente;//avanzamos al siguiente nodo y lo cargamos en temp 127 | 128 | } 129 | 130 | 131 | if (encontrado == false) { 132 | res = "clave y/o usuario erroneos van " + intentos + " fallidos"; 133 | javax.swing.JOptionPane.showMessageDialog(null, res); 134 | } 135 | if (intentos > 2) { 136 | javax.swing.JOptionPane.showMessageDialog(null, " 3 intentos fallidos, chao"); 137 | System.exit(0); 138 | } 139 | } 140 | 141 | 142 | 143 | 144 | 145 | //a-b-c-d 146 | //temp=a 147 | public void listar() { 148 | Nodo temp = inicio;//guardamos el nodo cabecera en temp al iniciara 149 | while (temp != null) {//mientras haya informaicón válida en el nodo 150 | System.out.println("usuario: " +temp.getInfo()+ " clave: "+temp.getInfo2());//cargamos la info del nodo actual en temp 151 | temp = temp.siguiente;//avanzamos al siguiente nodo y lo cargamos en temp 152 | } 153 | 154 | } 155 | 156 | 157 | private static void ordenarEmpleados(String tipOrden, List empList) { 158 | if ("1".equals(tipOrden)) { 159 | Collections.sort(empList, new Comparator() { 160 | @Override 161 | public int compare(Empleado e1, Empleado e2) { 162 | // toUpperCase() se convierte a mayusculas para que no importe el case 163 | return e1.getApellido().toUpperCase().compareTo(e2.getApellido().toUpperCase()); 164 | } 165 | }); 166 | } else { 167 | Collections.sort(empList, new Comparator() { 168 | @Override 169 | public int compare(Empleado e1, Empleado e2) { 170 | // toUpperCase() se convierte a mayusculas para que no importe el case 171 | return e1.getTipoContrato().toUpperCase().compareTo(e2.getTipoContrato().toUpperCase()); 172 | } 173 | }); 174 | } 175 | } 176 | 177 | 178 | 179 | } 180 | -------------------------------------------------------------------------------- /src/practicas/Nodo.java: -------------------------------------------------------------------------------- 1 | package practicas; 2 | 3 | public class Nodo { 4 | // Creamos los campos del nod: el contenedor(info) y el apuntador (siguiente) 5 | 6 | private String info; 7 | private String info2; 8 | Nodo siguiente; 9 | // | dato | sgte| 10 | 11 | /*creamos el constructor con los paramétors para recibir los datos de sus 12 | *campos en el nodo, observemos que gancho es de tipo Nodo*/ 13 | public Nodo(String dato, String dato2, Nodo gancho) { 14 | this.info = dato; 15 | this.info2 = dato2; 16 | this.siguiente = gancho; 17 | 18 | } 19 | 20 | // Método set Para el campo info 21 | public String getInfo() { 22 | return info; 23 | // observemos que String es el tipo de dato que devuelve este método 24 | } 25 | 26 | // Método set Para el campo info 27 | public void setInfo(String info) { 28 | this.info = info; 29 | 30 | } 31 | 32 | // Método set Para el campo info 33 | public String getInfo2() { 34 | return info2; 35 | // observemos que String es el tipo de dato que devuelve este método 36 | } 37 | 38 | // Método set Para el campo info 39 | public void setInfo2(String info2) { 40 | this.info2 = info2; 41 | 42 | } 43 | 44 | // Método get Para obtener la información del campo siguiente del nodo 45 | public Nodo getSiguiente() { 46 | return siguiente; 47 | // observemos que es "Nodo", el tipo de dato que devuelve este método 48 | } 49 | 50 | // Método set Para el campo siguiente 51 | public void setSiguiente(Nodo gancho) { 52 | this.siguiente = gancho; 53 | //observemos que es "Nodo", el tipo de dato que recibe como parámetor este método 54 | } 55 | 56 | }// fin de la clase 57 | -------------------------------------------------------------------------------- /src/practicas/Practica1.java: -------------------------------------------------------------------------------- 1 | package practicas; 2 | 3 | import java.io.IOException; 4 | import java.nio.charset.StandardCharsets; 5 | import java.nio.file.Files; 6 | import java.nio.file.Paths; 7 | import java.util.ArrayList; 8 | import java.util.Collections; 9 | import java.util.Comparator; 10 | import java.util.List; 11 | import java.util.Scanner; 12 | import java.util.regex.Pattern; 13 | /**ORDENAMIENTO DE LISTA DE EMPLEADOS: 14 | * Curso Java OCP 15 | * @authores:Alexander Narváez y Sebastian Londoño 16 | */ 17 | 18 | public class Practica1 { 19 | 20 | static final String rutaArchivo = "D:/Empleados.data"; 21 | 22 | public static void main(String[] args) { 23 | 24 | 25 | Scanner sc = new Scanner(System.in); 26 | 27 | System.out.println("Digite el tipo de ordenamineto, así: 1.Orden alfabético (apellido)" + " 2. Tipo de contrato:"); 28 | 29 | try { 30 | String tipOrden = sc.nextLine(); 31 | 32 | System.out.println(); 33 | List lineas = Files.readAllLines(Paths.get(rutaArchivo), StandardCharsets.ISO_8859_1); 34 | 35 | List empList = cargarEmpleados(lineas); 36 | 37 | ordenarEmpleados(tipOrden, empList); 38 | 39 | validarDatos(empList); 40 | 41 | imprimir(empList); 42 | } catch (IOException e) { 43 | e.printStackTrace(); 44 | } 45 | } 46 | 47 | private static void imprimir(List empList) { 48 | for (Empleado e : empList) { 49 | System.out.println(e); 50 | System.out.println(""); 51 | } 52 | } 53 | 54 | private static void validarDatos(List empList) { 55 | for (Empleado e : empList) { 56 | // Se valida si falto algún campo 57 | if ("".equals(e.getNombre()) || "".equals(e.getApellido()) || "".equals(e.getCedula()) || "".equals(e.getTelefono()) || "".equals(e.getSalario()) 58 | || "".equals(e.getTipoContrato()) || "".equals(e.getEstado())) { 59 | e.setValido(false); 60 | e.setQueMalo("Algo Vacio"); 61 | } else 62 | // Se valida el tipo de contrato 63 | if (!"INDEFINIDO".equals(e.getTipoContrato().toUpperCase()) && !"FIJO".equals(e.getTipoContrato().toUpperCase()) 64 | && !"SERVICIOS".equals(e.getTipoContrato().toUpperCase())) { 65 | e.setValido(false); 66 | e.setQueMalo("Tipo Contrato Erroneo"); 67 | } else { 68 | // Valida que el telefono sea valido 69 | String regex = "(\\(\\d+\\))?[\\d ]+"; 70 | if (!Pattern.matches(regex, e.getTelefono())) { 71 | e.setValido(false); 72 | e.setQueMalo("Teléfono malo"); 73 | } else { 74 | // Valida que el salario sea valido 75 | String salario = e.getSalario().trim(); 76 | if (salario.startsWith("$")) { 77 | salario = salario.substring(1); 78 | } 79 | try { 80 | Double.parseDouble(salario); 81 | 82 | // Se valida el estado 83 | if (!"ACTIVO".equals(e.getEstado().toUpperCase()) && !"PENSIONADO".equals(e.getEstado().toUpperCase()) 84 | && !"DESPEDIDO".equals(e.getEstado().toUpperCase()) && !"SUSPENDIDO".equals(e.getEstado().toUpperCase())) { 85 | e.setValido(false); 86 | e.setQueMalo("Estado Erroneo"); 87 | } 88 | } catch (NumberFormatException ex) { 89 | e.setValido(false); 90 | e.setQueMalo("Salario Malo"); 91 | } 92 | } 93 | } 94 | } 95 | } 96 | 97 | private static void ordenarEmpleados(String tipOrden, List empList) { 98 | if ("1".equals(tipOrden)) { 99 | Collections.sort(empList, new Comparator() { 100 | @Override 101 | public int compare(Empleado e1, Empleado e2) { 102 | // toUpperCase() se convierte a mayusculas para que no importe el case 103 | return e1.getApellido().toUpperCase().compareTo(e2.getApellido().toUpperCase()); 104 | } 105 | }); 106 | } else { 107 | Collections.sort(empList, new Comparator() { 108 | @Override 109 | public int compare(Empleado e1, Empleado e2) { 110 | // toUpperCase() se convierte a mayusculas para que no importe el case 111 | return e1.getTipoContrato().toUpperCase().compareTo(e2.getTipoContrato().toUpperCase()); 112 | } 113 | }); 114 | } 115 | } 116 | 117 | private static List cargarEmpleados(List lineas) { 118 | List empList = new ArrayList<>(lineas.size()); 119 | 120 | for (String emp : lineas) { 121 | String[] datosEmp = emp.split("\\|"); 122 | 123 | Empleado e = new Empleado(); 124 | switch (datosEmp.length) { 125 | case 7: 126 | e.setEstado(datosEmp[6]); 127 | case 6: 128 | e.setTipoContrato(datosEmp[5]); 129 | case 5: 130 | e.setSalario(datosEmp[4]); 131 | case 4: 132 | e.setTelefono(datosEmp[3]); 133 | case 3: 134 | e.setCedula(datosEmp[2]); 135 | case 2: 136 | e.setApellido(datosEmp[1]); 137 | case 1: 138 | e.setNombre(datosEmp[0]); 139 | } 140 | 141 | empList.add(e); 142 | } 143 | return empList; 144 | } 145 | } 146 | -------------------------------------------------------------------------------- /src/practicas/Practica3.java: -------------------------------------------------------------------------------- 1 | 2 | package practicas; 3 | 4 | /** 5 | * 6 | * @author Alexander Narváez 7 | */ 8 | public class Practica3 { 9 | 10 | 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/pruebas/AssertionsExample.java: -------------------------------------------------------------------------------- 1 | 2 | 3 | package pruebas; 4 | 5 | /** 6 | * 7 | * @author asus 8 | */ 9 | import java.util.Scanner; 10 | 11 | public class AssertionsExample{ 12 | public static void main(String[] args) { 13 | /* int x = -15; 14 | // DataAccess da = new DataAccess(); 15 | assert x > 0 : "El valor debe ser positivo"; 16 | System.out.println("Valor positivo x: " + x);*/ 17 | 18 | Scanner lector = new Scanner(System.in); 19 | System.out.println("Digite un número entre o y 10"); 20 | int assert=9; 21 | System.out.println(assert); 22 | int n= lector.nextInt(); 23 | 24 | assert ( n >=0 && n<=10): "número no válido " + n; 25 | System.out.println("Ud digito "+ n); 26 | } 27 | } 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /src/pruebas/PecesEnElRio.java: -------------------------------------------------------------------------------- 1 | package pruebas; 2 | 3 | /**Programa para que beban los peces en el río 4 | * 5 | * @author Alexander Narváez 6 | */ 7 | 8 | public class PecesEnElRio { 9 | 10 | public static void main(String[] ar) { 11 | boolean nacimiento = false; 12 | do { 13 | System.out.print("Beben y beben y vuelven a beber, " 14 | + "los peces en el río por ver al niño nacer \n"); 15 | 16 | } while (!nacimiento); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/pruebas/Temp_Test.java: -------------------------------------------------------------------------------- 1 | package pruebas; 2 | /** 3 | * 4 | * @author asus 5 | * Progrmaa que muestra el uso de etiquetas(labels) en java 6 | */ 7 | 8 | public class Temp_Test { 9 | 10 | public static void main(String[] args) { 11 | 12 | int k = 2; 13 | outer://eqtiqueta outer es similar a goto en vb 14 | while (true) { 15 | ++k; 16 | inner:// etiqueta inner 17 | for (int j = 6; j > 2; j--) { 18 | k = 8 - j; 19 | if (j == 3) { 20 | continue inner;//indica que debe continuar en la etiqueta "inner" 21 | } 22 | break outer;//indica que debe continuar en la etiqueta "outer" 23 | } 24 | continue outer;//indica que debe continuar en la etiqueta "outer" 25 | } 26 | 27 | System.out.println(k); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/pruebas/Test.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | 7 | package pruebas; 8 | 9 | public class Test { 10 | static int total = 10; 11 | public static void main (String args []) { 12 | new Test(); 13 | } 14 | public Test () { 15 | System.out.println("In test"); 16 | System.out.println(this); 17 | int temp = this.total; 18 | if (temp > 5) { 19 | System.out.println(temp); 20 | }}} -------------------------------------------------------------------------------- /src/pruebas/_$__$.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | 7 | package pruebas; 8 | 9 | import java.io.File; 10 | 11 | /** 12 | * 13 | * @author asus 14 | */ 15 | public class _$__$ { 16 | public static void main(String[] args) { 17 | String[] files=new String[100]; 18 | File search = new File("D:"); 19 | files=search.list(); 20 | for(String fn : files) 21 | 22 | System.out.println("Encontrado "+ fn); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/simuladores/BankBranch.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | 7 | package simuladores; 8 | 9 | /** 10 | * 11 | * @author asus 12 | */ 13 | public class BankBranch { 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/simuladores/Customer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package simuladores; 7 | 8 | /** 9 | * 10 | * @author Alexander Narváez 11 | */ 12 | public class Customer { 13 | 14 | String customerID; 15 | 16 | private String getCustomerID() { 17 | return customerID; 18 | } 19 | } 20 | 21 | class CreditCardCustomer extends Customer { 22 | 23 | public static void main(String[] args) { 24 | Customer brad = new CreditCardCustomer(); 25 | brad.customerID = "12122"; 26 | System.out.print(brad.getCustomerID()); 27 | } 28 | 29 | String getCustomerID() { 30 | return customerID; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/simuladores/Test.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | 7 | package simuladores; 8 | 9 | /** 10 | * 11 | * @author Alexander 12 | */ 13 | public class Test { 14 | public static void main(String[] args) { 15 | new Test().testMethod(); 16 | } 17 | 18 | void testMethod(){ 19 | try{ 20 | System.out.println("Java"); 21 | return; 22 | } 23 | finally{ 24 | System.exit(0); 25 | System.out.println("Tiger"); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/streams/Stderr.java: -------------------------------------------------------------------------------- 1 | 2 | package streams; 3 | 4 | /** 5 | * 6 | * @author Alexander Narváez 7 | */ 8 | import java.io.FileNotFoundException; 9 | import java.io.FileOutputStream; 10 | import java.io.IOException; 11 | import java.io.PrintStream; 12 | 13 | 14 | public class Stderr { 15 | public static void main(String[] args) throws FileNotFoundException, IOException { 16 | //abrimos el archivo y redireccionamos la salida standard error 17 | FileOutputStream fos = new FileOutputStream("errores.txt"); 18 | PrintStream stdErr= new PrintStream(fos); 19 | System.setErr(stdErr); 20 | 21 | int[] arr= new int[5]; 22 | 23 | for (int i=0; i< 10; i++){ 24 | 25 | arr[i]=0; 26 | } 27 | //cerramos todo 28 | stdErr.close(); 29 | fos.close(); 30 | } 31 | 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/strings/EjSplit.java: -------------------------------------------------------------------------------- 1 | package strings; 2 | 3 | class EjSplit { 4 | 5 | static public void main(String[] args) { 6 | 7 | String cadena = " ya, casí, salen"; 8 | String[] ninja = cadena.split("\\,"); 9 | for (String ninja1 : ninja) { 10 | System.out.println(ninja1); 11 | } 12 | 13 | int posComa = cadena.indexOf(","); 14 | 15 | System.out.println(posComa); 16 | 17 | String cadena2 = cadena.substring(posComa, cadena.length()); 18 | 19 | System.out.println(cadena2); 20 | 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/strings/EjStringBuffer.java: -------------------------------------------------------------------------------- 1 | package strings; 2 | 3 | public class EjStringBuffer { 4 | 5 | public static void main(String[] args) { 6 | String g = "g"; 7 | Long timeInicial = System.currentTimeMillis(); 8 | for (int i = 0; i < 10000; i++) { 9 | g = g + "o"; 10 | 11 | } 12 | Long timeFinal = System.currentTimeMillis(); 13 | long tt = timeFinal - timeInicial; 14 | 15 | System.out.println(tt + " milisegundos, utilizando el operador +"); 16 | 17 | //vamos con la clase StringBuffer 18 | timeInicial = System.currentTimeMillis(); 19 | StringBuffer sb = new StringBuffer(); 20 | for (int i = 0; i < 10000; i++) { 21 | // g=g+"o"; 22 | 23 | sb.append("o"); 24 | 25 | } 26 | 27 | timeFinal = System.currentTimeMillis(); 28 | tt = timeFinal - timeInicial; 29 | 30 | System.out.println(tt + " milisegundos, utilizando la clase StringBuffer"); 31 | 32 | //vamos con la clase StringBuffer 33 | timeInicial = System.currentTimeMillis(); 34 | StringBuilder sbui = new StringBuilder(); 35 | for (int i = 0; i < 10000; i++) { 36 | 37 | sbui.append("o"); 38 | 39 | } 40 | 41 | timeFinal = System.currentTimeMillis(); 42 | tt = timeFinal - timeInicial; 43 | 44 | System.out.println(tt + " milisegundos, utilizando la clase StringBuilder"); 45 | 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/strings/EjTokenizer.java: -------------------------------------------------------------------------------- 1 | package strings; 2 | 3 | import java.io.*; 4 | import java.util.StringTokenizer; 5 | import java.util.logging.*; 6 | 7 | public class EjTokenizer { 8 | 9 | public static void main(String[] args) { 10 | //permite crear un archivo en disco, ojo si no escriben ninja está malo 11 | File archivo = new File("D:/ninja.txt"); 12 | 13 | try { 14 | // creamos un object de la class FileWriter y le pasamos como parametro el archivo(objeto File anterior) 15 | FileWriter fw = new FileWriter(archivo); 16 | //Escribimos en Buffer con un objeto de esta clase y le pasamos como parametro un objecto de la clase FileWriter 17 | BufferedWriter bw = new BufferedWriter(fw); 18 | 19 | String cadena = " Yo, soy, ninja"; 20 | 21 | bw.write(cadena); 22 | bw.close(); 23 | 24 | StringTokenizer token=new StringTokenizer(cadena,","); 25 | cadena="";//limpiamos la cadena 26 | while(token.hasMoreTokens()){//mientras haya un token válido 27 | 28 | cadena+=token.nextToken();// lo acumulamos en cadena 29 | 30 | }//fin while 31 | 32 | System.out.println(cadena);//mostramos cadena 33 | 34 | 35 | } catch (IOException ex) { 36 | Logger.getLogger(EjTokenizer.class.getName()).log(Level.SEVERE, null, ex); 37 | } 38 | 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/strings/EjemploMatches2.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package strings; 7 | 8 | /** 9 | * 10 | * @author USER 11 | */ 12 | public class EjemploMatches2 { 13 | public static void main(String[] args) { 14 | 15 | String str1 = "Collection of tutorials"; 16 | String str2 = "Consists of different tutorials"; 17 | 18 | /* matches characters from index 14 in str1 to characters from 19 | index 22 in str2 considering same case of the letters */ 20 | boolean match1 = str1.regionMatches(14, str2, 22, 9); 21 | System.out.println("region matched = " + match1); 22 | 23 | /* considering different case, "true" is set which will ignore 24 | case when matched */ 25 | str2 = "Consists of different Tutorials"; 26 | match1 = str1.regionMatches(true, 14, str2, 22, 9); 27 | System.out.println("region matched = " + match1); 28 | } 29 | } 30 | 31 | -------------------------------------------------------------------------------- /src/strings/EjemploRegionMatches.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package strings; 7 | 8 | /** 9 | * 10 | * @author USER 11 | */ 12 | import java.io.*; 13 | public class EjemploRegionMatches { 14 | 15 | 16 | 17 | public static void main(String args[]){ 18 | String Str1 = new String("El amor todo lo puede"); 19 | String Str2 = new String("El amor"); 20 | String Str3 = new String("EL AMOR"); 21 | 22 | System.out.print("Return Value :" ); 23 | System.out.println(Str1.regionMatches(0, Str2, 0, 7)); 24 | 25 | System.out.print("Return Value :" ); 26 | System.out.println(Str1.regionMatches(11, Str3, 0, 9)); 27 | 28 | System.out.print("Return Value :" ); 29 | //Acáignora si es mayuscaula o minuscula, si son los mismos caracteres devuelve verdadero 30 | System.out.println(Str1.regionMatches(true,0, Str3, 0, 7)); 31 | } 32 | } 33 | 34 | 35 | -------------------------------------------------------------------------------- /src/strings/EjemploRegionMatches3.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package strings; 7 | 8 | /** 9 | * 10 | * @author USER 11 | */ 12 | public class EjemploRegionMatches3 { 13 | 14 | 15 | /* 16 | * This sample source code shows how to use the regionMatches method of String class 17 | */ 18 | 19 | 20 | public static void main(String[] args) { 21 | String source = "Alexander Narváez"; 22 | String anotherString = "Narváez el Mejor"; 23 | System.out.println(source.regionMatches(10, anotherString, 0, 6));//busque de la cadena1 a partir del indice 10 en la cadena 2 desde le indice 0 hasta el indice 6 24 | //es decir que va a buscar la palabra Narváez, ya que allí comienza el indice 10 25 | System.out.println(source.regionMatches(true,10, anotherString, 0, 6)); 26 | } 27 | 28 | } 29 | 30 | -------------------------------------------------------------------------------- /src/strings/EjemploSplit.java: -------------------------------------------------------------------------------- 1 | package strings; 2 | 3 | 4 | public class EjemploSplit { 5 | 6 | public static void main(String[] args) { 7 | 8 | String cadena = " Yo, soy, Ninja"; 9 | 10 | String[] ninja = cadena.split(","); 11 | 12 | for (int i = 0; i < ninja.length; i++) { 13 | 14 | System.out.print(ninja[i]); 15 | 16 | } 17 | 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/strings/EjemploToken.java: -------------------------------------------------------------------------------- 1 | package strings; 2 | 3 | import java.io.*; 4 | import java.util.StringTokenizer; 5 | import java.util.logging.*; 6 | 7 | public class EjemploToken { 8 | 9 | public static void main(String[] args) { 10 | //Utilizamos la clase File para crear un archivo en disco 11 | File archivo = new File("D:/ejemplo.txt"); 12 | try {//Se necita para controlar excepciones, como q el archivo no existe, esta bloqueado, etc 13 | //Necesitamos la Clase FileWriter para escribir en el archivo 14 | FileWriter fw = new FileWriter(archivo); 15 | 16 | //Finalmente escribimos en un Buffe, pasando como paramentro el objeto anterior(fw) 17 | BufferedWriter bw = new BufferedWriter(fw); 18 | 19 | //Creamos la pinche cadena con un pinche texto, ojo si no escribe Ninja está malo 20 | String cadena = " Yo, soy, Ninja"; 21 | //Escrimos la cadena en el archivo, por medio del método write del objeto bw 22 | bw.write(cadena); 23 | bw.close();//cerramos el objeto que escribe 24 | //Ahora vamos a procesar la cadena en tokens, por ello necesitamos la clase StringTokenizer 25 | //al objeto token le pasamos como parametro la cadena a procesar y el delimitador, en este caso la coma 26 | StringTokenizer token = new StringTokenizer(cadena, ","); 27 | cadena = "";//limpiamos la cadena para escribir de nuevo en ella, pero sin las comas en este caso 28 | while (token.hasMoreTokens()) {//mientras haya un token válido 29 | //almacenamos cada token procesado en la cadena 30 | cadena += token.nextToken(); 31 | }//fin dle ciclo 32 | System.out.println(cadena);//mostramos la pinche cadena 33 | 34 | } catch (IOException ex) { 35 | Logger.getLogger(EjemploToken.class.getName()).log(Level.SEVERE, null, ex); 36 | } 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/strings/EjmploStrings.java: -------------------------------------------------------------------------------- 1 | package strings; 2 | 3 | import java.io.*; 4 | import java.util.logging.*; 5 | 6 | public class EjmploStrings { 7 | 8 | public static void main(String[] args) { 9 | //Creamos un objeto de la clase File y le damos la ruta y el nombre del archivo 10 | File archivo = new File("D://lucas.txt"); 11 | try { 12 | 13 | //Creamos un objeto de la clase FileWriter para escribir el archivo en el Disco o unidad indicada en File 14 | FileWriter fw = new FileWriter(archivo); 15 | //Ojo si no escribes Ninja está malo 16 | String cadena = "Yo, soy, Ninja"; 17 | //Creamos un objeto de la clase BufferedWriter para escribir en Memoria y le pasamos fw como parametro 18 | BufferedWriter bw = new BufferedWriter(fw); 19 | bw.write(cadena);//utilizamos el método escribir del objeto bw y le pasamos cadena como parametro 20 | bw.close();//cerramos el objeto 21 | 22 | //Atrapamos cualquier excepción que se pueda presentar en tiempo de ejecución 23 | } catch (IOException ex) { 24 | Logger.getLogger(EjmploStrings.class.getName()).log(Level.SEVERE, null, ex); 25 | } 26 | 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/strings/IndexOf.java: -------------------------------------------------------------------------------- 1 | package strings; 2 | 3 | /** 4 | * 5 | * @author asus 6 | */ 7 | public class IndexOf { 8 | 9 | public static void main(String[] args) { 10 | /* El método indexOf devuelve la primera aparición de una cadena dentro de un String. 11 | Si le pasamos dos parámetros el primero será la cadena a buscar y el segundo la posición en la que empezará a buscar. 12 | El método substring devolverá una subcadena del String, desde la posición de inicio hasta la posición de fin. 13 | Si sólo se especifica un parámetro la subcadena contendrá desde la posición de inicio hasta el final de la cadena. 14 | Se ve más claro en el siguiente ejemplo:*/ 15 | 16 | String colores = "rojo,amarillo,verde,azul,morado,marrón"; 17 | 18 | int inicio = colores.indexOf(","); // , 19 | int fin = colores.indexOf(",", inicio + 1); //arranca desde la primera coma y busca la sgte + 1 pos amarillo 20 | 21 | System.out.println(colores.substring(inicio + 1, fin)); 22 | System.out.println(colores.substring(fin + 1)); 23 | 24 | 25 | 26 | 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/strings/Split.java: -------------------------------------------------------------------------------- 1 | package strings; 2 | /** 3 | * 4 | * @author Alexánder Narváez 5 | */ 6 | public class Split { 7 | 8 | public static void main(String[] args) { 9 | 10 | /*El método split devuelve un array de String. 11 | Es muy útil cuando tenemos un conjunto de elementos 12 | separados por comas. Por ejemplo*/ 13 | String colores = "rojo,amarillo,verde,azul,morado,marrón"; 14 | String[] arrayColores = colores.split(","); 15 | 16 | // En este momento tenemos un array en el que cada elemento es un color. 17 | for (int i = 0; i < arrayColores.length; i++) { 18 | System.out.println(arrayColores[i]); 19 | } 20 | 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/strings/Split_2.java: -------------------------------------------------------------------------------- 1 | package strings; 2 | 3 | import java.util.Scanner; 4 | 5 | public class Split_2 { 6 | 7 | public static void main(String[] args) { 8 | Scanner lector = new Scanner(System.in); 9 | System.out.println(" escriba alguna frase"); 10 | 11 | String frase = lector.nextLine(); 12 | 13 | String[] aFrase = frase.split(" "); 14 | 15 | // En este momento tenemos un array en el que cada elemento es un color. 16 | for (int i = aFrase.length - 1; i >= 0; i--) { 17 | System.out.print(aFrase[i]); 18 | }//fin ciclo 19 | System.out.println("El arreglo tiene " + aFrase.length + " elementos"); 20 | 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/strings/TestCadenas.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Progama para comparar las 3 formas de concatenar: 3 | * Operdador + 4 | *concat 5 | *StringBuffer con append 6 | * 7 | */ 8 | 9 | package strings; 10 | 11 | public class TestCadenas { 12 | private static final int cantidadPrueba = 10000; 13 | 14 | public static void main(String[] args) { 15 | concatenacionBString(); 16 | concatenacionConcat(); 17 | concatenacionSuma(); 18 | return; 19 | } 20 | 21 | private static void concatenacionSuma() { 22 | String resultado = "inicio"; 23 | for (int i = 0; i < cantidadPrueba; i++) { 24 | resultado += " hola"; 25 | } 26 | } 27 | 28 | private static void concatenacionConcat() { 29 | String resultado = "inicio"; 30 | for (int i = 0; i < cantidadPrueba; i++) { 31 | resultado.concat(" hola"); 32 | } 33 | } 34 | 35 | private static void concatenacionBString() { 36 | StringBuffer resultado = new StringBuffer("inicio"); 37 | for (int i = 0; i < cantidadPrueba; i++) { 38 | resultado.append(" hola"); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/strings/TokenSImple.java: -------------------------------------------------------------------------------- 1 | package strings; 2 | 3 | import java.util.StringTokenizer; 4 | 5 | public class TokenSImple { 6 | 7 | public static void main(String[] args) { 8 | String cadena = "Debo, estudiar, mucho, más"; 9 | StringTokenizer st = new StringTokenizer(cadena,","); 10 | while (st.hasMoreTokens()) { 11 | System.out.println(st.nextToken()); 12 | } 13 | 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/strings/Tokenizer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package strings; 7 | 8 | import java.io.File; 9 | import java.io.FileWriter; 10 | import java.io.BufferedWriter; 11 | import java.io.IOException; 12 | import java.util.StringTokenizer; 13 | import java.util.logging.Level; 14 | import java.util.logging.Logger; 15 | 16 | /** 17 | * 18 | * @author asus 19 | */ 20 | public class Tokenizer { 21 | 22 | public static void main(String[] args) { 23 | 24 | String cadena=" Yo, soy, Ninja"; 25 | // Cargamos un archivo a un objeot de la clase File 26 | File fichero = new File("D:/ninja.txt"); 27 | //creamos un objeto de tipo FileWriter, para poder escribir en el fichero 28 | //por ello pasamos"fiechero", como parámetro 29 | 30 | try { 31 | FileWriter fr = new FileWriter(fichero); 32 | //creamos un objeto de la clase BufferedWriter y le pasamos el objeto fr como parametro 33 | // esto se necesita para escribir en el buffer 34 | 35 | BufferedWriter br = new BufferedWriter(fr); 36 | //escribimos la cadema en el archivo y cerramos el Buffer 37 | br.write(cadena); 38 | br.close(); 39 | 40 | StringTokenizer tokens= new StringTokenizer(cadena); 41 | cadena=""; 42 | while(tokens.hasMoreTokens()){ 43 | 44 | cadena+=tokens.nextToken(); 45 | 46 | } 47 | 48 | System.out.println(cadena); 49 | 50 | 51 | 52 | 53 | 54 | } catch (IOException ex) { 55 | Logger.getLogger(Tokenizer.class.getName()).log(Level.SEVERE, null, ex); 56 | } 57 | 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /src/strings/Traductor.java: -------------------------------------------------------------------------------- 1 | package strings; 2 | 3 | /** 4 | * 5 | * @author NARVAEZ 6 | */ 7 | import java.io.File; 8 | import java.io.FileNotFoundException; 9 | import java.util.Scanner; 10 | 11 | public class Traductor { 12 | 13 | static String diccio[] = new String[10];//{"dios", "god", "te", "you", "ama", "loves"}; //temp=temp.replaceAll("[\n\r]",""); 14 | static String traducida = ""; 15 | static int opcion = 0; 16 | 17 | public static void main(String[] args) throws FileNotFoundException { 18 | int i = 0; String temp=""; 19 | Scanner sc = new Scanner(new File("D:\\words.txt")); //new Scanner(new File("esnumbers.txt")); 20 | // Scanner sc = new Scanner("amor,love,inglés,english,oso,bear"); 21 | sc.useDelimiter("[,\\s]"); 22 | while (sc.hasNext()) {// mientras haya una línea de texto 23 | diccio[i++] = sc.next(); 24 | } 25 | 26 | for (String elemento : diccio) { 27 | System.out.println(elemento); 28 | } 29 | leerFrase(); 30 | } 31 | 32 | static void leerFrase(){ 33 | System.out.println("Elija una opción para escribir la frase\n 1: Español \n 2. Inglés"); 34 | Scanner lector = new Scanner(System.in); 35 | opcion = lector.nextInt(); 36 | String peaje = lector.nextLine();// Esta línea debe de ir para evitar que nextline nos ignore la frase, asi peaje no se use 37 | 38 | System.out.println("Digite una frase para traducir"); 39 | String frase = lector.nextLine();// leemos la frase a traducir 40 | 41 | String[] palabras = frase.split(" ");// delimitador el espacio 42 | for (String palabra : palabras) { 43 | traducir(palabra); 44 | } 45 | 46 | System.out.println(traducida); 47 | } 48 | 49 | static void traducir(String palabra) { 50 | 51 | for (int i = 0; i < diccio.length; i++) { 52 | if (opcion == 1) { 53 | if (diccio[i].equals(palabra)) { 54 | traducida += diccio[i + 1] + " "; 55 | } 56 | } else if (opcion == 2) { 57 | 58 | if (diccio[i].equals(palabra)) { 59 | traducida += diccio[i - 1] + " "; 60 | } 61 | 62 | } 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/strings/Traductor_2.java: -------------------------------------------------------------------------------- 1 | package strings; 2 | 3 | /** 4 | * 5 | * @author NARVAEZ 6 | */ 7 | import java.io.File; 8 | import java.io.FileNotFoundException; 9 | import java.util.Scanner; 10 | 11 | public class Traductor_2 { 12 | 13 | static String diccio[] = new String[3]; 14 | 15 | public static void main(String[] args) { 16 | try { 17 | File f = new File("D:\\words.txt"); 18 | Scanner sc = new Scanner(f); 19 | 20 | int i = 0; 21 | while (sc.hasNextLine()) { 22 | String line = sc.nextLine(); 23 | String[] details = line.split(","); 24 | diccio[i] = details[0]; 25 | diccio[i + 1] = details[1]; 26 | i++; 27 | 28 | } 29 | 30 | } catch (FileNotFoundException e) { 31 | e.printStackTrace(); 32 | } 33 | 34 | for (String elemento : diccio) { 35 | System.out.println("La palabra actual es: " + elemento); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/strings/_T1.java: -------------------------------------------------------------------------------- 1 | package strings; 2 | 3 | import java.util.StringTokenizer; 4 | import java.util.Scanner; 5 | 6 | public class _T1 { 7 | 8 | public static void main(String[] args) { 9 | Scanner lector = new Scanner(System.in); 10 | 11 | System.out.println("Digite una frase"); 12 | String cadena = lector.nextLine(); 13 | 14 | 15 | 16 | 17 | 18 | StringTokenizer token = new StringTokenizer(cadena); 19 | cadena = "";//limpiamos la cadena 20 | while (token.hasMoreTokens()) {//mientras haya un token válido 21 | 22 | cadena += token.nextToken();// lo acumulamos en cadena 23 | 24 | }//fin while 25 | //creamos un arreglo para almacenar la cadena 26 | char pMatriz[][] = new char[cadena.length()][cadena.length()]; 27 | 28 | char[] aCaracteres = cadena.toCharArray(); 29 | 30 | for (int f = 0; f < pMatriz.length; f++) { 31 | for (int c = 0; c < pMatriz.length; c++) { 32 | if (f == c) { 33 | pMatriz[f][c] = aCaracteres[f]; 34 | //fin si 35 | } else { 36 | pMatriz[f][c] = ' '; 37 | }//fin del sino 38 | }//fin for interno 39 | 40 | }//fin del llenado de la diagonal ppal d la matriz 41 | 42 | for (int f = 0; f < pMatriz.length; f++) { 43 | for (int c = 0; c < pMatriz[f].length; c++) { 44 | System.out.print(pMatriz[f][c]); 45 | 46 | } 47 | System.out.println(""); 48 | }//fin del llenado de la matriz 49 | 50 | 51 | System.out.println(" La frase " + cadena + " tiene " + cadena.length() + " letras");//mostramos cadena 52 | 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /words.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elmaestrotic/certificationjava/6d844d9d9423f5dc1ebc67510e6bc215bfa1c7d0/words.txt --------------------------------------------------------------------------------