From c9037ed317ee961a999f4f4c21290583927a6005 Mon Sep 17 00:00:00 2001 From: tuzikuz Date: Fri, 12 Sep 2025 16:34:08 -0500 Subject: [PATCH] Update --- .gitignore | 22 +- README.md | 40 + .../project/.gitkeep | 0 makefile | 11 + .../base_de_datos}/README.md | 0 .../base_de_datos}/makefile | 0 .../base_de_datos}/pom.xml | 0 .../base_de_datos}/sql/1_db.sql | 0 .../base_de_datos}/sql/2_table.sql | 0 .../base_de_datos}/sql/3_insert.sql | 0 .../base_de_datos}/sql/4_debug.sql | 0 .../base_de_datos}/sql/backup.sql | 0 .../java/com/proy_final/Proy_final_db.java | 0 .../main/java/com/proy_final/mod/Init.java | 3 - .../java/com/proy_final/mod/db/DataBase.java | 0 .../com/proy_final/mod/template/Persona.java | 0 .../proy_final/mod/template/Ubicacion.java | 0 .../com/proy_final/mod/util/data/Cliente.java | 0 .../mod/util/data/Departamento.java | 0 .../proy_final/mod/util/data/Provincia.java | 0 .../proy_final/mod/util/data/Vendedor.java | 0 .../com/proy_final/mod/util/menu/NavBar.java | 0 .../menu/inicio/MenuInicioPresentacion.java | 0 .../MenuMantenimientoCliente.java | 0 .../MenuMantenimientoVendedor.java | 0 .../util/menu/reporte/MenuReporteCliente.java | 0 .../menu/reporte/MenuReporteVendedor.java | 0 .../proy_final/mod/util/settings/Global.java | 0 .../proy_final/mod/util/struct/Vec2x2.java | 0 .../view/PanelMantenimientoBoxCliente.java | 0 .../view/PanelMantenimientoBoxVendedor.java | 0 .../mod/util/view/PanelPresentacion.java | 0 .../mod/util/view/PanelReporteCliente.java | 0 .../mod/util/view/PanelReporteVendedor.java | 0 .../util/view/gui/PanelMantenimientoBox.java | 0 .../resources/reports/reporte_cliente.jrxml | 0 .../main/resources/reports/reporte_none.jrxml | 0 .../resources/reports/reporte_vendedor.jrxml | 0 project/cafeteria/README.tex | 328 +++++ project/cafeteria/makefile | 8 + project/cafeteria/src/Main.java | 9 + .../cafeteria/src/cafeteria/Restaurante.java | 540 ++++++++ .../src/cafeteria/clientela/Cliente.java | 20 + .../cafeteria/clientela/ClientePedido.java | 16 + .../src/cafeteria/productos/Gastronomia.java | 43 + .../alcohol/CervezaCristalizada.java | 10 + .../productos/alcohol/VinoVerde.java | 10 + .../productos/alimento/FlorDeLuna.java | 10 + .../productos/alimento/GalletaDorada.java | 10 + .../productos/alimento/GalletaRoja.java | 10 + .../productos/alimento/PanDulce.java | 10 + .../productos/bebida/CafeConLeche.java | 10 + .../cafeteria/productos/bebida/CafeNegro.java | 10 + .../cafeteria/productos/bebida/Limonada.java | 10 + .../enjambre_de_langosta/META-INF/MANIFEST.MF | 3 + .../META-INF/manifest.txt | 3 + project/enjambre_de_langosta/README.md | 1 + .../build/Ault_977_Proy1.jar | Bin 0 -> 11946 bytes project/enjambre_de_langosta/makefile | 15 + .../enjambre_de_langosta/src/com/Proy1.java | 11 + .../src/com/mod/Init.java | 1123 +++++++++++++++++ .../src/com/mod/utils/GameButton.java | 8 + .../src/com/mod/utils/Vec2x2.java | 27 + .../juego_de_adivinanza_de_numeros/Main.java | 66 + .../juego_de_adivinanza_de_numeros/makefile | 3 + project/rompecabeza/META-INF/MANIFEST.MF | 3 + project/rompecabeza/META-INF/manifest.txt | 3 + project/rompecabeza/Makefile | 15 + project/rompecabeza/README.md | 17 + project/rompecabeza/build/Proy2.jar | Bin 0 -> 13450 bytes project/rompecabeza/build/storage/data.ini | 1 + project/rompecabeza/src/com/Proy2.java | 12 + project/rompecabeza/src/com/mod/Init.java | 849 +++++++++++++ .../src/com/mod/util/GameButton.java | 11 + .../src/com/mod/util/UserData.java | 7 + .../rompecabeza/src/com/mod/util/Vec2D.java | 11 + .../rompecabeza/src/com/mod/util/Vec2x2.java | 25 + 77 files changed, 3338 insertions(+), 6 deletions(-) create mode 100755 README.md rename base_de_datos/src/main/resources/reports/reporte_none.jrxml => base/project/.gitkeep (100%) create mode 100644 makefile rename {base_de_datos => project/base_de_datos}/README.md (100%) rename {base_de_datos => project/base_de_datos}/makefile (100%) rename {base_de_datos => project/base_de_datos}/pom.xml (100%) rename {base_de_datos => project/base_de_datos}/sql/1_db.sql (100%) rename {base_de_datos => project/base_de_datos}/sql/2_table.sql (100%) rename {base_de_datos => project/base_de_datos}/sql/3_insert.sql (100%) rename {base_de_datos => project/base_de_datos}/sql/4_debug.sql (100%) rename {base_de_datos => project/base_de_datos}/sql/backup.sql (100%) rename {base_de_datos => project/base_de_datos}/src/main/java/com/proy_final/Proy_final_db.java (100%) rename {base_de_datos => project/base_de_datos}/src/main/java/com/proy_final/mod/Init.java (99%) rename {base_de_datos => project/base_de_datos}/src/main/java/com/proy_final/mod/db/DataBase.java (100%) rename {base_de_datos => project/base_de_datos}/src/main/java/com/proy_final/mod/template/Persona.java (100%) rename {base_de_datos => project/base_de_datos}/src/main/java/com/proy_final/mod/template/Ubicacion.java (100%) rename {base_de_datos => project/base_de_datos}/src/main/java/com/proy_final/mod/util/data/Cliente.java (100%) rename {base_de_datos => project/base_de_datos}/src/main/java/com/proy_final/mod/util/data/Departamento.java (100%) rename {base_de_datos => project/base_de_datos}/src/main/java/com/proy_final/mod/util/data/Provincia.java (100%) rename {base_de_datos => project/base_de_datos}/src/main/java/com/proy_final/mod/util/data/Vendedor.java (100%) rename {base_de_datos => project/base_de_datos}/src/main/java/com/proy_final/mod/util/menu/NavBar.java (100%) rename {base_de_datos => project/base_de_datos}/src/main/java/com/proy_final/mod/util/menu/inicio/MenuInicioPresentacion.java (100%) rename {base_de_datos => project/base_de_datos}/src/main/java/com/proy_final/mod/util/menu/mantenimiento/MenuMantenimientoCliente.java (100%) rename {base_de_datos => project/base_de_datos}/src/main/java/com/proy_final/mod/util/menu/mantenimiento/MenuMantenimientoVendedor.java (100%) rename {base_de_datos => project/base_de_datos}/src/main/java/com/proy_final/mod/util/menu/reporte/MenuReporteCliente.java (100%) rename {base_de_datos => project/base_de_datos}/src/main/java/com/proy_final/mod/util/menu/reporte/MenuReporteVendedor.java (100%) rename {base_de_datos => project/base_de_datos}/src/main/java/com/proy_final/mod/util/settings/Global.java (100%) rename {base_de_datos => project/base_de_datos}/src/main/java/com/proy_final/mod/util/struct/Vec2x2.java (100%) rename {base_de_datos => project/base_de_datos}/src/main/java/com/proy_final/mod/util/view/PanelMantenimientoBoxCliente.java (100%) rename {base_de_datos => project/base_de_datos}/src/main/java/com/proy_final/mod/util/view/PanelMantenimientoBoxVendedor.java (100%) rename {base_de_datos => project/base_de_datos}/src/main/java/com/proy_final/mod/util/view/PanelPresentacion.java (100%) rename {base_de_datos => project/base_de_datos}/src/main/java/com/proy_final/mod/util/view/PanelReporteCliente.java (100%) rename {base_de_datos => project/base_de_datos}/src/main/java/com/proy_final/mod/util/view/PanelReporteVendedor.java (100%) rename {base_de_datos => project/base_de_datos}/src/main/java/com/proy_final/mod/util/view/gui/PanelMantenimientoBox.java (100%) rename {base_de_datos => project/base_de_datos}/src/main/resources/reports/reporte_cliente.jrxml (100%) create mode 100644 project/base_de_datos/src/main/resources/reports/reporte_none.jrxml rename {base_de_datos => project/base_de_datos}/src/main/resources/reports/reporte_vendedor.jrxml (100%) create mode 100755 project/cafeteria/README.tex create mode 100755 project/cafeteria/makefile create mode 100755 project/cafeteria/src/Main.java create mode 100755 project/cafeteria/src/cafeteria/Restaurante.java create mode 100755 project/cafeteria/src/cafeteria/clientela/Cliente.java create mode 100755 project/cafeteria/src/cafeteria/clientela/ClientePedido.java create mode 100755 project/cafeteria/src/cafeteria/productos/Gastronomia.java create mode 100755 project/cafeteria/src/cafeteria/productos/alcohol/CervezaCristalizada.java create mode 100755 project/cafeteria/src/cafeteria/productos/alcohol/VinoVerde.java create mode 100755 project/cafeteria/src/cafeteria/productos/alimento/FlorDeLuna.java create mode 100755 project/cafeteria/src/cafeteria/productos/alimento/GalletaDorada.java create mode 100755 project/cafeteria/src/cafeteria/productos/alimento/GalletaRoja.java create mode 100755 project/cafeteria/src/cafeteria/productos/alimento/PanDulce.java create mode 100755 project/cafeteria/src/cafeteria/productos/bebida/CafeConLeche.java create mode 100755 project/cafeteria/src/cafeteria/productos/bebida/CafeNegro.java create mode 100755 project/cafeteria/src/cafeteria/productos/bebida/Limonada.java create mode 100644 project/enjambre_de_langosta/META-INF/MANIFEST.MF create mode 100644 project/enjambre_de_langosta/META-INF/manifest.txt create mode 100755 project/enjambre_de_langosta/README.md create mode 100644 project/enjambre_de_langosta/build/Ault_977_Proy1.jar create mode 100755 project/enjambre_de_langosta/makefile create mode 100755 project/enjambre_de_langosta/src/com/Proy1.java create mode 100755 project/enjambre_de_langosta/src/com/mod/Init.java create mode 100755 project/enjambre_de_langosta/src/com/mod/utils/GameButton.java create mode 100755 project/enjambre_de_langosta/src/com/mod/utils/Vec2x2.java create mode 100755 project/juego_de_adivinanza_de_numeros/Main.java create mode 100755 project/juego_de_adivinanza_de_numeros/makefile create mode 100644 project/rompecabeza/META-INF/MANIFEST.MF create mode 100644 project/rompecabeza/META-INF/manifest.txt create mode 100755 project/rompecabeza/Makefile create mode 100644 project/rompecabeza/README.md create mode 100644 project/rompecabeza/build/Proy2.jar create mode 100644 project/rompecabeza/build/storage/data.ini create mode 100755 project/rompecabeza/src/com/Proy2.java create mode 100644 project/rompecabeza/src/com/mod/Init.java create mode 100755 project/rompecabeza/src/com/mod/util/GameButton.java create mode 100644 project/rompecabeza/src/com/mod/util/UserData.java create mode 100644 project/rompecabeza/src/com/mod/util/Vec2D.java create mode 100644 project/rompecabeza/src/com/mod/util/Vec2x2.java diff --git a/.gitignore b/.gitignore index 26f78e3..fa1c3ae 100755 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,19 @@ -*.class -*.log -*.tmp \ No newline at end of file +# Java +**/.class +**/.jar + +# IDE / Editor +## VS code / VS Codium +**/.vscode/ + +# Git +**/.git/ +!/.git/ + + +# Temporal +## Folders +**/trash/ +## Files +**/.log +**/.tmp \ No newline at end of file diff --git a/README.md b/README.md new file mode 100755 index 0000000..ac3e445 --- /dev/null +++ b/README.md @@ -0,0 +1,40 @@ +# Java + +## Install: + +### Oracle + +[Oracle | Cloud Applications and Cloud Platform](https://www.oracle.com/) + +[Java Downloads | Oracle](https://www.oracle.com/java/technologies/downloads/) + +### Adoptium + +[Adoption](https://adoptium.net) + +[Adoption releases](https://adoptium.net/es/temurin/releases/) + + +```sh +apt install -y wget apt-transport-https gpg +wget -qO - https://packages.adoptium.net/artifactory/api/gpg/key/public | gpg --dearmor | tee /etc/apt/trusted.gpg.d/adoptium.gpg > /dev/null +echo "deb https://packages.adoptium.net/artifactory/deb $(awk -F= '/^VERSION_CODENAME/{print$2}' /etc/os-release) main" | tee /etc/apt/sources.list.d/adoptium.list +apt update +apt install temurin-17-jdk +``` + +### Maven + +```shell +sudo apt install maven + +mvn -version +``` + +## Commands + +```java +javac Main.java +java Main +``` + diff --git a/base_de_datos/src/main/resources/reports/reporte_none.jrxml b/base/project/.gitkeep similarity index 100% rename from base_de_datos/src/main/resources/reports/reporte_none.jrxml rename to base/project/.gitkeep diff --git a/makefile b/makefile new file mode 100644 index 0000000..160dbf3 --- /dev/null +++ b/makefile @@ -0,0 +1,11 @@ +purge: + find . -name "*.class" -type f -delete + + +# Windows Command Powershell: +purge_windows: + powershell -Command "Get-ChildItem -Recurse -Include *.class,*.log,*.tmp,*~ | Remove-Item -Force" + +# Linux Command +purge_linux: + find . -name "*.class" -type f -delete \ No newline at end of file diff --git a/base_de_datos/README.md b/project/base_de_datos/README.md similarity index 100% rename from base_de_datos/README.md rename to project/base_de_datos/README.md diff --git a/base_de_datos/makefile b/project/base_de_datos/makefile similarity index 100% rename from base_de_datos/makefile rename to project/base_de_datos/makefile diff --git a/base_de_datos/pom.xml b/project/base_de_datos/pom.xml similarity index 100% rename from base_de_datos/pom.xml rename to project/base_de_datos/pom.xml diff --git a/base_de_datos/sql/1_db.sql b/project/base_de_datos/sql/1_db.sql similarity index 100% rename from base_de_datos/sql/1_db.sql rename to project/base_de_datos/sql/1_db.sql diff --git a/base_de_datos/sql/2_table.sql b/project/base_de_datos/sql/2_table.sql similarity index 100% rename from base_de_datos/sql/2_table.sql rename to project/base_de_datos/sql/2_table.sql diff --git a/base_de_datos/sql/3_insert.sql b/project/base_de_datos/sql/3_insert.sql similarity index 100% rename from base_de_datos/sql/3_insert.sql rename to project/base_de_datos/sql/3_insert.sql diff --git a/base_de_datos/sql/4_debug.sql b/project/base_de_datos/sql/4_debug.sql similarity index 100% rename from base_de_datos/sql/4_debug.sql rename to project/base_de_datos/sql/4_debug.sql diff --git a/base_de_datos/sql/backup.sql b/project/base_de_datos/sql/backup.sql similarity index 100% rename from base_de_datos/sql/backup.sql rename to project/base_de_datos/sql/backup.sql diff --git a/base_de_datos/src/main/java/com/proy_final/Proy_final_db.java b/project/base_de_datos/src/main/java/com/proy_final/Proy_final_db.java similarity index 100% rename from base_de_datos/src/main/java/com/proy_final/Proy_final_db.java rename to project/base_de_datos/src/main/java/com/proy_final/Proy_final_db.java diff --git a/base_de_datos/src/main/java/com/proy_final/mod/Init.java b/project/base_de_datos/src/main/java/com/proy_final/mod/Init.java similarity index 99% rename from base_de_datos/src/main/java/com/proy_final/mod/Init.java rename to project/base_de_datos/src/main/java/com/proy_final/mod/Init.java index 478251c..26d19a7 100644 --- a/base_de_datos/src/main/java/com/proy_final/mod/Init.java +++ b/project/base_de_datos/src/main/java/com/proy_final/mod/Init.java @@ -15,9 +15,6 @@ import javax.swing.JPanel; public class Init extends JFrame implements ActionListener { - - - public Init() { this.setTitle("Proy Final"); this.setLayout(null); diff --git a/base_de_datos/src/main/java/com/proy_final/mod/db/DataBase.java b/project/base_de_datos/src/main/java/com/proy_final/mod/db/DataBase.java similarity index 100% rename from base_de_datos/src/main/java/com/proy_final/mod/db/DataBase.java rename to project/base_de_datos/src/main/java/com/proy_final/mod/db/DataBase.java diff --git a/base_de_datos/src/main/java/com/proy_final/mod/template/Persona.java b/project/base_de_datos/src/main/java/com/proy_final/mod/template/Persona.java similarity index 100% rename from base_de_datos/src/main/java/com/proy_final/mod/template/Persona.java rename to project/base_de_datos/src/main/java/com/proy_final/mod/template/Persona.java diff --git a/base_de_datos/src/main/java/com/proy_final/mod/template/Ubicacion.java b/project/base_de_datos/src/main/java/com/proy_final/mod/template/Ubicacion.java similarity index 100% rename from base_de_datos/src/main/java/com/proy_final/mod/template/Ubicacion.java rename to project/base_de_datos/src/main/java/com/proy_final/mod/template/Ubicacion.java diff --git a/base_de_datos/src/main/java/com/proy_final/mod/util/data/Cliente.java b/project/base_de_datos/src/main/java/com/proy_final/mod/util/data/Cliente.java similarity index 100% rename from base_de_datos/src/main/java/com/proy_final/mod/util/data/Cliente.java rename to project/base_de_datos/src/main/java/com/proy_final/mod/util/data/Cliente.java diff --git a/base_de_datos/src/main/java/com/proy_final/mod/util/data/Departamento.java b/project/base_de_datos/src/main/java/com/proy_final/mod/util/data/Departamento.java similarity index 100% rename from base_de_datos/src/main/java/com/proy_final/mod/util/data/Departamento.java rename to project/base_de_datos/src/main/java/com/proy_final/mod/util/data/Departamento.java diff --git a/base_de_datos/src/main/java/com/proy_final/mod/util/data/Provincia.java b/project/base_de_datos/src/main/java/com/proy_final/mod/util/data/Provincia.java similarity index 100% rename from base_de_datos/src/main/java/com/proy_final/mod/util/data/Provincia.java rename to project/base_de_datos/src/main/java/com/proy_final/mod/util/data/Provincia.java diff --git a/base_de_datos/src/main/java/com/proy_final/mod/util/data/Vendedor.java b/project/base_de_datos/src/main/java/com/proy_final/mod/util/data/Vendedor.java similarity index 100% rename from base_de_datos/src/main/java/com/proy_final/mod/util/data/Vendedor.java rename to project/base_de_datos/src/main/java/com/proy_final/mod/util/data/Vendedor.java diff --git a/base_de_datos/src/main/java/com/proy_final/mod/util/menu/NavBar.java b/project/base_de_datos/src/main/java/com/proy_final/mod/util/menu/NavBar.java similarity index 100% rename from base_de_datos/src/main/java/com/proy_final/mod/util/menu/NavBar.java rename to project/base_de_datos/src/main/java/com/proy_final/mod/util/menu/NavBar.java diff --git a/base_de_datos/src/main/java/com/proy_final/mod/util/menu/inicio/MenuInicioPresentacion.java b/project/base_de_datos/src/main/java/com/proy_final/mod/util/menu/inicio/MenuInicioPresentacion.java similarity index 100% rename from base_de_datos/src/main/java/com/proy_final/mod/util/menu/inicio/MenuInicioPresentacion.java rename to project/base_de_datos/src/main/java/com/proy_final/mod/util/menu/inicio/MenuInicioPresentacion.java diff --git a/base_de_datos/src/main/java/com/proy_final/mod/util/menu/mantenimiento/MenuMantenimientoCliente.java b/project/base_de_datos/src/main/java/com/proy_final/mod/util/menu/mantenimiento/MenuMantenimientoCliente.java similarity index 100% rename from base_de_datos/src/main/java/com/proy_final/mod/util/menu/mantenimiento/MenuMantenimientoCliente.java rename to project/base_de_datos/src/main/java/com/proy_final/mod/util/menu/mantenimiento/MenuMantenimientoCliente.java diff --git a/base_de_datos/src/main/java/com/proy_final/mod/util/menu/mantenimiento/MenuMantenimientoVendedor.java b/project/base_de_datos/src/main/java/com/proy_final/mod/util/menu/mantenimiento/MenuMantenimientoVendedor.java similarity index 100% rename from base_de_datos/src/main/java/com/proy_final/mod/util/menu/mantenimiento/MenuMantenimientoVendedor.java rename to project/base_de_datos/src/main/java/com/proy_final/mod/util/menu/mantenimiento/MenuMantenimientoVendedor.java diff --git a/base_de_datos/src/main/java/com/proy_final/mod/util/menu/reporte/MenuReporteCliente.java b/project/base_de_datos/src/main/java/com/proy_final/mod/util/menu/reporte/MenuReporteCliente.java similarity index 100% rename from base_de_datos/src/main/java/com/proy_final/mod/util/menu/reporte/MenuReporteCliente.java rename to project/base_de_datos/src/main/java/com/proy_final/mod/util/menu/reporte/MenuReporteCliente.java diff --git a/base_de_datos/src/main/java/com/proy_final/mod/util/menu/reporte/MenuReporteVendedor.java b/project/base_de_datos/src/main/java/com/proy_final/mod/util/menu/reporte/MenuReporteVendedor.java similarity index 100% rename from base_de_datos/src/main/java/com/proy_final/mod/util/menu/reporte/MenuReporteVendedor.java rename to project/base_de_datos/src/main/java/com/proy_final/mod/util/menu/reporte/MenuReporteVendedor.java diff --git a/base_de_datos/src/main/java/com/proy_final/mod/util/settings/Global.java b/project/base_de_datos/src/main/java/com/proy_final/mod/util/settings/Global.java similarity index 100% rename from base_de_datos/src/main/java/com/proy_final/mod/util/settings/Global.java rename to project/base_de_datos/src/main/java/com/proy_final/mod/util/settings/Global.java diff --git a/base_de_datos/src/main/java/com/proy_final/mod/util/struct/Vec2x2.java b/project/base_de_datos/src/main/java/com/proy_final/mod/util/struct/Vec2x2.java similarity index 100% rename from base_de_datos/src/main/java/com/proy_final/mod/util/struct/Vec2x2.java rename to project/base_de_datos/src/main/java/com/proy_final/mod/util/struct/Vec2x2.java diff --git a/base_de_datos/src/main/java/com/proy_final/mod/util/view/PanelMantenimientoBoxCliente.java b/project/base_de_datos/src/main/java/com/proy_final/mod/util/view/PanelMantenimientoBoxCliente.java similarity index 100% rename from base_de_datos/src/main/java/com/proy_final/mod/util/view/PanelMantenimientoBoxCliente.java rename to project/base_de_datos/src/main/java/com/proy_final/mod/util/view/PanelMantenimientoBoxCliente.java diff --git a/base_de_datos/src/main/java/com/proy_final/mod/util/view/PanelMantenimientoBoxVendedor.java b/project/base_de_datos/src/main/java/com/proy_final/mod/util/view/PanelMantenimientoBoxVendedor.java similarity index 100% rename from base_de_datos/src/main/java/com/proy_final/mod/util/view/PanelMantenimientoBoxVendedor.java rename to project/base_de_datos/src/main/java/com/proy_final/mod/util/view/PanelMantenimientoBoxVendedor.java diff --git a/base_de_datos/src/main/java/com/proy_final/mod/util/view/PanelPresentacion.java b/project/base_de_datos/src/main/java/com/proy_final/mod/util/view/PanelPresentacion.java similarity index 100% rename from base_de_datos/src/main/java/com/proy_final/mod/util/view/PanelPresentacion.java rename to project/base_de_datos/src/main/java/com/proy_final/mod/util/view/PanelPresentacion.java diff --git a/base_de_datos/src/main/java/com/proy_final/mod/util/view/PanelReporteCliente.java b/project/base_de_datos/src/main/java/com/proy_final/mod/util/view/PanelReporteCliente.java similarity index 100% rename from base_de_datos/src/main/java/com/proy_final/mod/util/view/PanelReporteCliente.java rename to project/base_de_datos/src/main/java/com/proy_final/mod/util/view/PanelReporteCliente.java diff --git a/base_de_datos/src/main/java/com/proy_final/mod/util/view/PanelReporteVendedor.java b/project/base_de_datos/src/main/java/com/proy_final/mod/util/view/PanelReporteVendedor.java similarity index 100% rename from base_de_datos/src/main/java/com/proy_final/mod/util/view/PanelReporteVendedor.java rename to project/base_de_datos/src/main/java/com/proy_final/mod/util/view/PanelReporteVendedor.java diff --git a/base_de_datos/src/main/java/com/proy_final/mod/util/view/gui/PanelMantenimientoBox.java b/project/base_de_datos/src/main/java/com/proy_final/mod/util/view/gui/PanelMantenimientoBox.java similarity index 100% rename from base_de_datos/src/main/java/com/proy_final/mod/util/view/gui/PanelMantenimientoBox.java rename to project/base_de_datos/src/main/java/com/proy_final/mod/util/view/gui/PanelMantenimientoBox.java diff --git a/base_de_datos/src/main/resources/reports/reporte_cliente.jrxml b/project/base_de_datos/src/main/resources/reports/reporte_cliente.jrxml similarity index 100% rename from base_de_datos/src/main/resources/reports/reporte_cliente.jrxml rename to project/base_de_datos/src/main/resources/reports/reporte_cliente.jrxml diff --git a/project/base_de_datos/src/main/resources/reports/reporte_none.jrxml b/project/base_de_datos/src/main/resources/reports/reporte_none.jrxml new file mode 100644 index 0000000..e69de29 diff --git a/base_de_datos/src/main/resources/reports/reporte_vendedor.jrxml b/project/base_de_datos/src/main/resources/reports/reporte_vendedor.jrxml similarity index 100% rename from base_de_datos/src/main/resources/reports/reporte_vendedor.jrxml rename to project/base_de_datos/src/main/resources/reports/reporte_vendedor.jrxml diff --git a/project/cafeteria/README.tex b/project/cafeteria/README.tex new file mode 100755 index 0000000..43852a8 --- /dev/null +++ b/project/cafeteria/README.tex @@ -0,0 +1,328 @@ +\documentclass[a4paper, 12pt]{article} +\usepackage[bookmarks=true, unicode]{hyperref} +\usepackage{bookmark} + +\usepackage{fontawesome} + +\usepackage[spanish]{babel} +\usepackage[utf8]{inputenc} + +\usepackage{graphicx} + +\usepackage{listings} +\usepackage{xcolor} + +\renewcommand{\lstlistingname}{Código} +\definecolor{codegreen}{rgb}{0,0.6,0} +\definecolor{codegray}{rgb}{0.5,0.5,0.5} +\definecolor{codepurple}{rgb}{0.58,0,0.82} +\definecolor{backcolour}{rgb}{0.98,0.98,0.98} + +\lstdefinestyle{mystyle}{ + backgroundcolor=\color{backcolour}, + commentstyle=\color{codegreen}, + keywordstyle=\color{magenta}, + numberstyle=\tiny\color{codegray}, + stringstyle=\color{codepurple}, + basicstyle=\ttfamily\footnotesize, + breakatwhitespace=false, + breaklines=true, + captionpos=b, + keepspaces=true, + numbers=left, + numbersep=5pt, + showspaces=false, + showstringspaces=false, + showtabs=false, + tabsize=2, + basicstyle=\ttfamily, + moredelim=[il][\textcolor{pgrey}]{$$}, + moredelim=[is][\textcolor{pgrey}]{\%\%}{\%\%} +} + +\lstset{style=mystyle} +\setlength{\parindent}{0pt} + + +\title{Cafeteria} +\author{Tuzikuz} +\date{\today} + +\raggedright + + +% enumitem clashes with enumerate +\usepackage{enumitem,amssymb} +\newlist{todolist}{itemize}{2} +\setlist[todolist]{label=$\square$} + +\usepackage{pifont} +\newcommand{\cmark}{\ding{51}}% +\newcommand{\xmark}{\ding{55}}% +\newcommand{\done}{\rlap{$\square$}{\raisebox{2pt}{\large\hspace{1pt}\cmark}}% +\hspace{-2.5pt}} +\newcommand{\wontfix}{\rlap{$\square$}{\large\hspace{1pt}\xmark}} + + +% \begin{lstlisting}[language=Java, caption=Enum java] \end{lstlisting} +% \vspace{0.5cm} + +\begin{document} +\maketitle + + +\newpage + + +\tableofcontents + +\section{TODO} + +\begin{todolist} + \item[\done] Inicio + + \item[\done] Ver menu + \begin{todolist} + \item[\done] Ver detalles + \end{todolist} + + \item[\done] Pedidos + \begin{todolist} + \item[\done] Refund + \item[\done] Mis productos + \item[\done] Recargar saldo + \item[\done] Reducir saldo + \item[\done] Eliminar pedido + \item[\done] Factura + \end{todolist} + + \item[\done] Debug +\end{todolist} + + \section{Index} + + \subsection{Paginas} + \url{https://www.youtube.com} + + \url{https://www.digitalocean.com} + + \url{https://stackoverflow.com} + + \url{https://www.w3schools.com} + + \url{https://www.javatpoint.com} + + \url{https://forums.oracle.com} + + \url{https://www.cs.utexas.edu} + + \url{www.edureka.co} + + + + + \section{Printf in java} + + \begin{lstlisting}[ + language=Java, + caption=Printf java, + extendedchars=true, + inputencoding=utf8, + literate={á}{{\'a}}1 {ã}{{\~a}}1 {é}{{\'e}}1, + ] +/* +Format Specifiers +Lets look at the available format specifiers available for printf: + +%c character +%d decimal (integer) number (base 10) +%e exponential floating-point number +%f floating-point number +%i integer (base 10) +%o octal number (base 8) +%s String +%u unsigned decimal (integer) number +%x number in hexadecimal (base 16) +%t formats date/time +%% print a percent sign +\% print a percent sign + + +Escape Characters +Following are the escape characters available in printf(): + +\b backspace +\f next line first character starts to the right of current line last character +\n newline +\r carriage return +\t tab +\\ backslash +*/ + +int var = 10; +System.out.printf("%i", var);\end{lstlisting} + + \vspace{0.5cm} + + \href{https://www.digitalocean.com/community/tutorials/java-printf-method}{Java printf() - Print Formatted String to Console | DigitalOcean} + + + + + \begin{lstlisting}[language=Java, caption=String format] +int a = 1, b = 2, c = 3; + +return String.format("%d %d %d", a, b, c);\end{lstlisting}\vspace{0.5cm} + + \href{https://www.geeksforgeeks.org/java-string-format-method-with-examples/}{Java String format() Method With Examples - GeeksforGeeks} + + \vspace{0.3cm} + \href{https://stackoverflow.com/questions/23461344/can-a-return-statement-be-formatted-like-a-printf}{java - Can a return statement be formatted like a printf? - Stack Overflow} + + \vspace{0.3cm} + \href{https://www.digitalocean.com/community/tutorials/java-printf-method}{Java printf() - Print Formatted String to Console | DigitalOcean} + + + + + \section{Enum} + + \begin{lstlisting}[language=Java, caption=Enum java] +enum Level { + LOW, + MEDIUM, + HIGH +} + +Level myVar = Level.MEDIUM;\end{lstlisting}\vspace{0.5cm} + + \href{https://www.w3schools.com/java/java_enums.asp}{w3schools Java Enums} + + \vspace{0.3cm} + \href{https://stackoverflow.com/questions/23058275/should-i-use-uppercase-or-camelcase-in-label-enums}{stackoverflow java - Should I use uppercase or camelcase in label enums? - Stack Overflow} + + \vspace{0.3cm} + \href{https://stackoverflow.com/questions/8143995/should-java-member-enum-types-be-capitalized}{stackoverflow eclipse - Should Java member enum types be capitalized? - Stack Overflow} + + + + + \section{Set and get} + \begin{lstlisting}[language=Java, caption=Set get] +public class Person { + private String name; // private = restricted access + + // Getter + public String getName() { + return name; + } + + // Setter + public void setName(String newName) { + this.name = newName; + } +} + \end{lstlisting} + \href{https://www.w3schools.com/java/java_encapsulation.asp}{Java Encapsulation and Getters and Setters} + + + + + \section{Extends and List} + \begin{lstlisting}[language=Java, caption=Extends List] +// You could use java generic.First create a java collection (ex: List) with supper class type, Product. Now you could add any sub classes (Monitor , Keyboard etc) in your collection (List) that extends of class Product. + + +public class Product{} +public class Monitor extends Product{} + +public class Keyboard extends Product{} + +List products = new ArrayList(); +products.add(new Monitor()); +products.add(new Keyboard());\end{lstlisting}\vspace{0.5cm} + + \href{https://stackoverflow.com/questions/18288655/storing-multiple-object-types-in-a-list}{java - Storing multiple object types in a List - Stack Overflow} + + \vspace{0.3cm} + \href{https://es.stackoverflow.com/questions/496024/c%C3%B3digo-en-java-con-arraylist-y-herencia}{Código en Java con arrayList y herencia - Stack Overflow en español]} + + \vspace{0.3cm} + \href{https://www.javatpoint.com/arraylist-implementation-in-java}{ArrayList Implementation in Java - Javatpoint} + + \vspace{0.3cm} + \href{https://forums.oracle.com/ords/apexds/post/to-extend-arraylist-or-to-not-extend-arraylist-1665}{To extend ArrayList, or to not extend ArrayList - Oracle Forums} + + \vspace{0.3cm} + \href{https://www.w3resource.com/java-exercises/oop/java-oop-exercise-18.php}{Java - Restaurant menu, average rating} + + \vspace{0.3cm} + \href{https://www.w3schools.com/java/java_inheritance.asp}{Java Inheritance (Subclass and Superclass)} + \vspace{0.5cm} + + \begin{enumerate} + \item Class array: \href{https://youtu.be/QTPIYcQ6Cxc?t=1100}{ArrayList inheritance Everything - YouTube} + \item super(): \href{https://youtu.be/QTPIYcQ6Cxc?t=2426}{ArrayList inheritance Everything - YouTube} + \item Return string: \href{https://youtu.be/QTPIYcQ6Cxc?t=2629}{ArrayList inheritance Everything - YouTube} + \end{enumerate} + + + \section{Package} + + \begin{lstlisting}[language=Java, caption=Enum java] +import mytest.Mypckg; + +public class Learn { + public static void main(String[] args) { + System.out.println("Hello World"); + Mypckg.show(); + } +} +package mytest; +public class Mypckg { + public static void show(){ + System.out.println("Good Moring"); + } +} + \end{lstlisting}\vspace{0.5cm} + + \href{https://stackoverflow.com/questions/63868318/how-to-import-class-of-one-file-to-another-in-a-subfolder-in-java-using-vscode}{How to import class of one file to another in a subfolder in Java using vscode - Stack Overflow} + + \vspace{0.3cm} + \href{https://stackoverflow.com/questions/26432953/java-import-sub-sub-directory}{Java import sub-sub directory - Stack Overflow} + + \vspace{0.3cm} + \href{https://www.youtube.com/watch?v=PsuZ0WxDJ0M}{How To Import A Class In Java From Another Package or Project - Java Tutorial - YouTube} + + \vspace{0.3cm} + \href{https://www.youtube.com/watch?v=3ybNZM6cP3M}{Calling Java class from other file in Visual Studio Code - YouTube} + + \vspace{0.5cm} + + + \section{User input} + \begin{lstlisting}[language=Java, caption=Normal input] +InputStreamReader inputStreamReader new InputStreamReader (System.in); + +BufferedReader buffer = new BufferedReader (inputStreamReader); + +String userInput = buffer.readLine(); + +int userInputToInt = Integer.parseInt(userInput); +\end{lstlisting}\vspace{1cm} + + \begin{lstlisting}[language=Java, caption=Others input] +BufferedReader buffer = new BufferedReader (new InputStreamReader (System.in)); + +int userInput = Integer.parseInt(buffer.readLine());\end{lstlisting}\vspace{0.5cm} + + \href{https://www.cs.utexas.edu/~mitra/csSpring2004/cs313/assgn/BufferedReader.html#:~:text=BufferedReader%20input%20%3D%20new%20BufferedReader%20(new,readLine()%3B}{Using Buffered Readers} + + \vspace{0.3cm} + \href{https://stackoverflow.com/questions/25491997/how-to-read-multiple-integer-values-from-one-line-in-java-using-bufferedreader-o}{arrays - How to read multiple integer values from one line in Java using BufferedReader object? - Stack Overflow} + + \vspace{0.3cm} + \href{https://www.edureka.co/community/40038/how-to-take-input-using-bufferedreader-in-java}{How to take input using BufferedReader in Java | Edureka Community} + + +\end{document} \ No newline at end of file diff --git a/project/cafeteria/makefile b/project/cafeteria/makefile new file mode 100755 index 0000000..9d53e17 --- /dev/null +++ b/project/cafeteria/makefile @@ -0,0 +1,8 @@ +all: + cd ./src && javac Main.java && java Main + +latex: + pdflatex README.tex + +clear: + del /s /q *.class *.log *.aux *.toc \ No newline at end of file diff --git a/project/cafeteria/src/Main.java b/project/cafeteria/src/Main.java new file mode 100755 index 0000000..a42abcf --- /dev/null +++ b/project/cafeteria/src/Main.java @@ -0,0 +1,9 @@ +import cafeteria.Restaurante; + +public class Main { + public static void main(String[] args) { + Restaurante restaurante = new Restaurante(); + restaurante.db(); + restaurante.start(); + } +} \ No newline at end of file diff --git a/project/cafeteria/src/cafeteria/Restaurante.java b/project/cafeteria/src/cafeteria/Restaurante.java new file mode 100755 index 0000000..8226452 --- /dev/null +++ b/project/cafeteria/src/cafeteria/Restaurante.java @@ -0,0 +1,540 @@ +package cafeteria; + +import cafeteria.clientela.Cliente; +import cafeteria.clientela.ClientePedido; + +import cafeteria.productos.Gastronomia; +import cafeteria.productos.Gastronomia.GastronomiaTypo; + +import cafeteria.productos.alcohol.*; +import cafeteria.productos.bebida.*; +import cafeteria.productos.alimento.*; + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.io.IOException; +import java.util.ArrayList; + +public class Restaurante { + private BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in)); + + private Cliente cliente; + + public Restaurante() { + try { + System.out.printf("%nIngrese sus datos (Cliente):%n"); + + System.out.printf("Cual es tu...%n"); + System.out.printf("Nombre: "); + String nombre = bufferedReader.readLine(); + + System.out.printf("Edad: "); + int edad = Integer.parseInt(bufferedReader.readLine()); + + System.out.printf("Dinero: "); + float dinero = Float.parseFloat(bufferedReader.readLine()); + + cliente = new Cliente(nombre, edad, dinero); + + System.out.printf("%nBienvenido a la cafeteria %s%n", cliente.getNombre()); + + } catch (IOException e) { + System.out.println("Ocurrio un error de entrada/salida:" + e.getMessage()); + } catch (NumberFormatException e) { + System.out.println("Por favor, ingresa solo numeros validos."); + } + } + + ArrayList drain = new ArrayList(); + private int mainID = -1; + + public int getID() { + return this.mainID += 1; + } + + ArrayList gastronomia = new ArrayList(); + public void db() { + gastronomia.add(new CafeNegro(getID(), 25, 1f)); + gastronomia.add(new CafeConLeche(getID(), 25, 1.25f)); + gastronomia.add(new CervezaCristalizada(getID(), 20, 4.05f)); + gastronomia.add(new Limonada(getID(), 5, 3.25f)); + gastronomia.add(new VinoVerde(getID(), 5, 5.25f)); + gastronomia.add(new FlorDeLuna(getID(), 20, 2.45f)); + gastronomia.add(new GalletaRoja(getID(), 13, 3.0f)); + gastronomia.add(new PanDulce(getID(), 22, 1.25f)); + gastronomia.add(new GalletaDorada(getID(), 1, 9999999.99f)); + } + + int userInput, userInputID, userInputCantidad; + boolean end = false; + boolean start = true; + boolean menu = false, menuDetalles = false; + boolean pedido = false, pedidoTerminado = false, pedidoSalir = false, pedidoVer = false, pedidoSaldo = false, inputDrain; + float subTotal = 0; + + + public void menuPedido() { + System.out.printf("%n%n--------------------------------------------------------------%n"); + System.out.printf("|%20s%-20s%20s|%n", "", "MENU DE PRODUCTOS ", ""); + System.out.printf("--------------------------------------------------------------%n"); + System.out.printf("| %-5s | %-15s | %-17s | %11s |%n", "Numero", "Nombre", "Disponibilidad", "Precio"); + System.out.printf("--------------------------------------------------------------%n"); + for (int i = 0; i < gastronomia.size(); i += 1) { + System.out.printf("| %-6d | %-15s | %-17d | %11.2f |%n", i, gastronomia.get(i).getNombre(), gastronomia.get(i).getStock(), gastronomia.get(i).getPrecio()); + System.out.printf("--------------------------------------------------------------%n"); + } + } + + ArrayList clientePedidos = new ArrayList(); + public void start() { + try { + while(true) { + subTotal = 0; + userInput = 0; + if (end) { + System.out.printf("%nSaliendo...%n"); + System.exit(0); + } + + if (start) { + start = false; + System.out.printf("%n"); + System.out.printf("--------------------------------------------------------------%n"); + System.out.printf("|%20s%-20s%20s|%n", "", "Cafeteria Sin Nombre", ""); + System.out.printf("--------------------------------------------------------------%n"); + System.out.printf("|%-60s|%n", "1. Ver menu"); + System.out.printf("|%-60s|%n", "2. Hacer pedido"); + System.out.printf("|%-60s|%n", "3. Salir"); + System.out.printf("--------------------------------------------------------------%n"); + if (inputDrain) { + inputDrain = false; + for (int i = 0; i < drain.size(); i += 1) { + System.out.printf(String.format(drain.get(i))); + } + } + System.out.printf("Ingrese una opcion: "); + userInput = Integer.parseInt(bufferedReader.readLine()); + + switch(userInput) { + case 1: + menu = true; + continue; + case 2: + pedido = true; + continue; + case 3: + end = true; + continue; + default: + start = true; + System.out.printf("%nOpcion Invalida intente de nuevo%n"); + continue; + } + } + + if (menu) { + menu = false; + menuPedido(); + + System.out.printf("1. Inicio%n"); + System.out.printf("2. Ver detalles%n"); + System.out.printf("3. Hacer pedido%n"); + System.out.printf("4. Salir%n"); + System.out.printf("--------------------------------------------------------------%n"); + System.out.printf("Ingrese una opcion: "); + userInput = Integer.parseInt(bufferedReader.readLine()); + + + switch(userInput) { + case 1: + start = true; + continue; + case 2: + menuDetalles = true; + continue; + case 3: + pedido = true; + continue; + case 4: + end = true; + continue; + default: + start = true; + System.out.printf("%nOpcion Invalida intente de nuevo%n"); + continue; + } + } + + if (menuDetalles) { + menuDetalles = false; + System.out.printf("%n%n--------------------------------------------------------------%n"); + System.out.printf("|%18s%-20s%18s|%n", "", "DESCRIPCION DE PRODUCTOS", ""); + System.out.printf("--------------------------------------------------------------%n"); + for (int i = 0; i < gastronomia.size(); i += 1) { + System.out.printf("| %-5s | %-15s | %-40s%n", i, gastronomia.get(i).getNombre(), gastronomia.get(i).getDescripcion()); + System.out.printf("--------------------------------------------------------------%n"); + } + System.out.printf("1. Inicio%n"); + System.out.printf("2. Menu%n"); + System.out.printf("3. Hacer pedido%n"); + System.out.printf("4. Salir%n"); + System.out.printf("--------------------------------------------------------------%n"); + System.out.printf("Ingrese una opcion: "); + userInput = Integer.parseInt(bufferedReader.readLine()); + switch(userInput) { + case 1: + start = true; + continue; + case 2: + menu = true; + continue; + case 3: + pedido = true; + continue; + case 4: + end = true; + continue; + default: + start = true; + System.out.printf("%nOpcion Invalida intente de nuevo%n"); + continue; + } + } + + if (pedido) { + menuPedido(); + System.out.printf("|%20s%-20s%20s|%n", "", "Haciendo pedido...", ""); + System.out.printf("--------------------------------------------------------------%n"); + System.out.printf("Ingrese el producto que desea%n"); + System.out.printf("-1 Para salir%n"); + System.out.printf("ID: "); + userInputID = Integer.parseInt(bufferedReader.readLine()); + + switch (userInputID) { + case -1: + break; + default: + System.out.printf("Cantidad: "); + userInputCantidad = Integer.parseInt(bufferedReader.readLine()); + } + System.out.printf("--------------------------------------------------------------"); + + if (userInputID == -1 || userInputCantidad == -1) { + pedidoSalir = true; + } + + if (pedidoSalir == false && 0 > userInputID || gastronomia.size() < userInputID) { + System.out.printf("%nProducto no encontrado, intente de nuevo.%n"); + continue; + } + + if (pedidoSalir == false && userInputCantidad <= 0) { + System.out.printf("%nLa cantidad pedida es 0 o menor, intente de nuevo.%n"); + continue; + } + + if (pedidoSalir == false && gastronomia.get(userInputID).getStock() - userInputCantidad < 0) { + System.out.printf("%n%nLa cantidad pedida es mayor de la que tenemos, intente de nuevo.%n"); + continue; + } + + if (pedidoSalir == false && cliente.getDinero() < gastronomia.get(userInputID).getPrecio() * userInputCantidad) { + System.out.printf("%nUsted no tiene el suficiente saldo para adquirir este producto, intente agregar mas saldo..%n"); + continue; + } + + if (pedidoSalir == false && cliente.getEdad() < 18 && gastronomia.get(userInputID).getTypo() == GastronomiaTypo.ALCOHOL) { + System.out.printf("%nUsted no tiene la edad suficiente para adquirir este producto, intente de nuevo.%n"); + continue; + } + + + if (pedidoSalir == false) { + clientePedidos.add(new ClientePedido(gastronomia.get(userInputID).getID(), userInputCantidad)); + + gastronomia.get(userInputID).setStockSub(userInputCantidad); + + System.out.printf("%n%nAgrego[ID:%d, Nombre:%s, Contidad:%d] | Stock: %d %n", + gastronomia.get(userInputID).getID(), + gastronomia.get(userInputID).getNombre(), + userInputCantidad, + gastronomia.get(userInputID).getStock() + ); + } + + pedidoSalir = false; + System.out.printf("%n--------------------------------------------------------------%n"); + System.out.printf("1. Terminar pedido%n"); + System.out.printf("2. Hacer otro pedido%n"); + System.out.printf("3. Volver%n"); + System.out.printf("4. Mis productos%n"); + System.out.printf("5. Agregar saldo%n"); + System.out.printf("--------------------------------------------------------------%n"); + System.out.printf("Ingrese una opcion: "); + userInput = Integer.parseInt(bufferedReader.readLine()); + + switch (userInput) { + case 1: + if (clientePedidos.size() == 0) { + System.out.printf("%nNo podemos terminar tu pedido si no ha pedido nada, "); + System.out.printf("si desea volver sin pedir nada intente con la opcion:%n"); + System.out.printf("3. Volver.%n%n"); + continue; + } + + for (int i = 0; i < clientePedidos.size(); i += 1) { + int indexPtr = clientePedidos.get(i).getPtr(); + int indexCantidad = clientePedidos.get(i).getCantidad(); + + for (int x = 0; x < gastronomia.size(); x += 1) { + if (gastronomia.get(x).getID() == indexPtr) { + subTotal += indexCantidad * gastronomia.get(x).getPrecio(); + } + } + } + + if (cliente.getDinero() < subTotal) { + System.out.printf("%nUsted no tiene el suficiente saldo para terminar su pedido. intente eliminar algun producto.%n"); + subTotal = 0; + continue; + } + pedido = false; + pedidoTerminado = true; + continue; + case 2: + continue; + case 3: + pedido = false; + + for (int i = 0; i < clientePedidos.size(); i += 1) { + int indexPtr = clientePedidos.get(i).getPtr(); + int indexCantidad = clientePedidos.get(i).getCantidad(); + + for (int x = 0; x < gastronomia.size(); x += 1) { + if (gastronomia.get(x).getID() == indexPtr) { + gastronomia.get(x).setStockAdd(indexCantidad); + + System.out.printf("Ha devuelto: [idPedido: %d, idProducto: %d, Nombre: %s, Cantidad: %d] %n", + i, + gastronomia.get(x).getID(), + gastronomia.get(x).getNombre(), + indexCantidad + ); + break; + } + } + } + + for (int i = 0; i < clientePedidos.size(); i += 1) { + clientePedidos.remove(i); + } + + start = true; + continue; + case 4: + pedido = false; + pedidoVer = true; + continue; + case 5: + pedido = false; + pedidoSaldo = true; + continue; + default: + System.out.printf("%nOpcion Invalida intente de nuevo%n"); + continue; + } + } + + if (pedidoSaldo) { + pedidoSaldo = false; + pedido = true; + System.out.printf("--------------------------------------------------------------%n"); + System.out.printf("%nCuanto saldo desea agregar: "); + cliente.setDineroAdd(Integer.parseInt(bufferedReader.readLine())); + System.out.printf("--------------------------------------------------------------%n"); + System.out.printf("Tu saldo actual es: %.2f %n", cliente.getDinero()); + System.out.printf("--------------------------------------------------------------%n"); + } + + if (pedidoVer) { + if ( clientePedidos.size() == 0) { + System.out.printf("%nUsted carece de algun producto, intente pedir uno.%n"); + pedido = true; + continue; + } + + System.out.printf("%n--------------------------------------------------------------%n"); + System.out.printf("|%20s%-20s%20s|%n", "", "Tus productos", ""); + System.out.printf("--------------------------------------------------------------%n"); + System.out.printf("|%-8s|%-10s|%-14s|%-10s|%-8s|%-10s|%n", "IDPedido", "IDProducto", "Nombre", "Precio", "Cantidad", "Total"); + System.out.printf("--------------------------------------------------------------%n"); + for (int i = 0; i < clientePedidos.size(); i += 1) { + System.out.printf("|%-8d|%-10d|%-14s|%-10.2f|%-8d|%-10.2f|%n", + i, + clientePedidos.get(i).getPtr(), + gastronomia.get(clientePedidos.get(i).getPtr()).getNombre(), + gastronomia.get(clientePedidos.get(i).getPtr()).getPrecio(), + clientePedidos.get(i).getCantidad(), + gastronomia.get(clientePedidos.get(i).getPtr()).getPrecio() * clientePedidos.get(i).getCantidad() + ); + System.out.printf("--------------------------------------------------------------%n"); + subTotal += gastronomia.get(clientePedidos.get(i).getPtr()).getPrecio() * clientePedidos.get(i).getCantidad(); + } + + System.out.printf("%nSubtotal: %.2f%n", subTotal); + System.out.printf("--------------------------------------------------------------%n"); + System.out.printf("Tu saldo: %.2f%n", cliente.getDinero()); + System.out.printf("--------------------------------------------------------------%n"); + System.out.printf("1. Recargar saldo%n"); + System.out.printf("2. Reducir saldo%n"); + System.out.printf("3. Eliminar pedido%n"); + System.out.printf("4. Volver%n"); + System.out.printf("--------------------------------------------------------------%n"); + System.out.printf("Input: "); + userInputID = Integer.parseInt(bufferedReader.readLine()); + + switch (userInputID) { + case 1: + System.out.printf("--------------------------------------------------------------%n"); + System.out.printf("%nCuanto saldo desea agregar: "); + cliente.setDineroAdd(Integer.parseInt(bufferedReader.readLine())); + System.out.printf("--------------------------------------------------------------%n"); + System.out.printf("Tu saldo actual es: %.2f %n", cliente.getDinero()); + System.out.printf("--------------------------------------------------------------%n"); + continue; + case 2: + System.out.printf("%nCuanto desea reducir: "); + float sub = Float.parseFloat(bufferedReader.readLine()); + if (cliente.getDinero() < sub) { + System.out.printf("El saldo restado en mayor de lo que tiene, Intente de nuevo%n"); + continue; + } + cliente.setDineroSub(sub); + System.out.printf("--------------------------------------------------------------%n"); + System.out.printf("Tu saldo total es: %.2f %n", cliente.getDinero()); + System.out.printf("--------------------------------------------------------------%n"); + continue; + case 3: + System.out.printf("--------------------------------------------------------------%n"); + System.out.printf("Que pedido desea eliminar o modificar?%n"); + System.out.printf("--------------------------------------------------------------%n"); + System.out.printf("-1 Para salir%n"); + System.out.printf("ID: "); + + userInputID = Integer.parseInt(bufferedReader.readLine()); + if (userInputID == -1) { + continue; + } + + System.out.printf("Cantidad: "); + userInputCantidad = Integer.parseInt(bufferedReader.readLine()); + if (userInputCantidad == -1) { + continue; + } + + if (userInputID > gastronomia.size()) { + System.out.printf("Este pedido no esta en la lista. intentale de nuevo.%n"); + continue; + } + + if (true) { /*For fun uwu/ Claim the reward box */ + if (userInputID == -300) { + drain.add("%n%n%n uwu/ Esto es un easter egg. %n%n Reclame su caja misteriosa... %n%n Caja misteriosa: \"El premio son los conocimiento que hicimos en el camino\". owo/ %n%n%n"); + inputDrain = true; + } + } + + if (userInputID < 0 || userInputCantidad < 0) { + System.out.printf("%nLos pedidos -0 no existen, intente de nuevo.%n"); + continue; + } + + if (clientePedidos.get(userInputID).getCantidad() < userInputCantidad) { + System.out.printf("La cantidad a remover es mayor de la que pidio.%n"); + continue; + } + + System.out.printf("%n"); + + for (int i = 0; i < gastronomia.size(); i += 1) { + int indexPtr = clientePedidos.get(userInputID).getPtr(); + int indexCantidad = userInputCantidad; + + if (gastronomia.get(i).getID() == indexPtr) { + + gastronomia.get(i).setStockAdd(indexCantidad); + clientePedidos.get(userInputID).setCantidadSub(indexCantidad); + if (clientePedidos.get(userInputID).getCantidad() == 0) { + clientePedidos.remove(userInputID); + } + + System.out.printf("Ha devuelto: [idPedido: %d, idProducto: %d, Nombre: %s, Cantidad: %d] %n", + indexPtr, + gastronomia.get(i).getID(), + gastronomia.get(i).getNombre(), + indexCantidad + ); + break; + + + } + } + break; + case 4: + pedidoVer = false; + pedido = true; + continue; + default: + pedidoVer = false; + pedido = true; + System.out.printf("%nOpcion Invalida intente de nuevo%n"); + continue; + } + + } + + if (pedidoTerminado) { + System.out.printf("%n%n--------------------------------------------------------------%n"); + System.out.printf("|Recibo de: %s%n", cliente.getNombre()); + System.out.printf("--------------------------------------------------------------%n"); + System.out.printf("|%-2s|%-23s|%-10s|%-10s|%-11s|%n", "id", "Nombre", "Precio", "Cantidad", "Total"); + System.out.printf("--------------------------------------------------------------%n"); + + for (int i = 0; i < clientePedidos.size(); i += 1) { + int indexPtr = clientePedidos.get(i).getPtr(); + int indexCantidad = clientePedidos.get(i).getCantidad(); + + for (int x = 0; x < gastronomia.size(); x += 1) { + if (gastronomia.get(x).getID() == indexPtr) { + System.out.printf("|%-2d|%-23s|%-10.2f|%-10d|%-11.2f|%n", + i, + gastronomia.get(x).getNombre(), + gastronomia.get(x).getPrecio(), + indexCantidad, + indexCantidad * gastronomia.get(x).getPrecio() + ); + System.out.printf("--------------------------------------------------------------%n"); + subTotal += indexCantidad * gastronomia.get(x).getPrecio(); + } + } + + } + + System.out.printf("Total a pagar: %.2f", subTotal); + System.out.printf("%n--------------------------------------------------------------%n"); + System.out.printf("Total tu saldo: %.2f", cliente.getDinero() - subTotal); + System.out.printf("%n--------------------------------------------------------------%n"); + System.out.printf("|%19s%20s%20s|%n", "", "Gracias por su compra", ""); + System.out.printf("--------------------------------------------------------------%n"); + + end = true; + continue; + } + } + } catch (IOException e) { + System.out.println("Ocurrio un error de entrada/salida:" + e.getMessage()); + } catch (NumberFormatException e) { + System.out.println("Por favor, ingresa solo numeros validos."); + } + } +} \ No newline at end of file diff --git a/project/cafeteria/src/cafeteria/clientela/Cliente.java b/project/cafeteria/src/cafeteria/clientela/Cliente.java new file mode 100755 index 0000000..c10c52d --- /dev/null +++ b/project/cafeteria/src/cafeteria/clientela/Cliente.java @@ -0,0 +1,20 @@ +package cafeteria.clientela; + +public class Cliente { + private String nombre; + private int edad; + private float dinero; + + public Cliente(String nombre, int edad, float dinero) { + this.nombre = nombre; + this.edad = edad; + this.dinero = dinero; + } + + public String getNombre() { return this.nombre; } + public int getEdad() { return this.edad; } + public float getDinero() { return this.dinero; } + + public void setDineroAdd(float dinero) { this.dinero += dinero; } + public void setDineroSub(float dinero) { this.dinero -= dinero; } +} \ No newline at end of file diff --git a/project/cafeteria/src/cafeteria/clientela/ClientePedido.java b/project/cafeteria/src/cafeteria/clientela/ClientePedido.java new file mode 100755 index 0000000..b5ef336 --- /dev/null +++ b/project/cafeteria/src/cafeteria/clientela/ClientePedido.java @@ -0,0 +1,16 @@ +package cafeteria.clientela; + +public class ClientePedido { + private int idPtr, cantidad; + + public ClientePedido(int idPtr, int cantidad) { + this.idPtr = idPtr; + this.cantidad = cantidad; + } + + public int getPtr() { return this.idPtr; } + public int getCantidad() { return this.cantidad; } + + public void setCantidadAdd(int num) { this.cantidad += num; } + public void setCantidadSub(int num) { this.cantidad -= num; } +} \ No newline at end of file diff --git a/project/cafeteria/src/cafeteria/productos/Gastronomia.java b/project/cafeteria/src/cafeteria/productos/Gastronomia.java new file mode 100755 index 0000000..63b5676 --- /dev/null +++ b/project/cafeteria/src/cafeteria/productos/Gastronomia.java @@ -0,0 +1,43 @@ +package cafeteria.productos; + +public class Gastronomia { + public enum GastronomiaTypo { + BEBIDA, + ALIMENTO, + ALCOHOL + } + + private int id; + private String nombre; + private int cantidad, stock; + private float precio; + private GastronomiaTypo typo; + private String descripcion; + + public Gastronomia(int id, String nombre, int cantidad, float precio, GastronomiaTypo typo, String descripcion) { + this.id = id; + this.nombre = nombre; + this.cantidad = cantidad; + this.stock = cantidad; + this.precio = precio; + this.typo = typo; + this.descripcion = descripcion; + } + + public void setNombre(String nombre) { this.nombre = nombre; } + public void setCantidadAdd(int cantidad) { this.cantidad += cantidad; } + public void setCantidadSub(int cantidad) { this.cantidad -= cantidad; } + public void setStockAdd(int stock) { this.stock += stock; } + public void setStockSub(int stock) { this.stock -= stock; } + public void setPrecio(float precio) { this.precio = precio; } + public void setTypo(GastronomiaTypo typo) { this.typo = typo; } + public void setDescripcion(String descripcion) { this.descripcion = descripcion; } + + public int getID() { return this.id; } + public String getNombre() { return this.nombre; } + public int getCantidad() { return this.cantidad; } + public int getStock() { return this.stock; } + public float getPrecio() { return this.precio; } + public GastronomiaTypo getTypo() { return this.typo; } + public String getDescripcion() { return this.descripcion; } +} \ No newline at end of file diff --git a/project/cafeteria/src/cafeteria/productos/alcohol/CervezaCristalizada.java b/project/cafeteria/src/cafeteria/productos/alcohol/CervezaCristalizada.java new file mode 100755 index 0000000..94ca61d --- /dev/null +++ b/project/cafeteria/src/cafeteria/productos/alcohol/CervezaCristalizada.java @@ -0,0 +1,10 @@ +package cafeteria.productos.alcohol; + +import cafeteria.productos.Gastronomia; +import cafeteria.productos.Gastronomia.GastronomiaTypo; + +public class CervezaCristalizada extends Gastronomia { + public CervezaCristalizada(int id, int cantidad, float precio) { + super(id, "Cristalizada", cantidad, precio, GastronomiaTypo.ALCOHOL, "Cerveza con una sensacion cristalizada al beberla"); + } +} \ No newline at end of file diff --git a/project/cafeteria/src/cafeteria/productos/alcohol/VinoVerde.java b/project/cafeteria/src/cafeteria/productos/alcohol/VinoVerde.java new file mode 100755 index 0000000..6362501 --- /dev/null +++ b/project/cafeteria/src/cafeteria/productos/alcohol/VinoVerde.java @@ -0,0 +1,10 @@ +package cafeteria.productos.alcohol; + +import cafeteria.productos.Gastronomia; +import cafeteria.productos.Gastronomia.GastronomiaTypo; + +public class VinoVerde extends Gastronomia { + public VinoVerde(int id, int cantidad, float precio) { + super(id, "Vino verde", cantidad, precio, GastronomiaTypo.ALCOHOL, String.format("Vino con un regusto picante")); + } +} \ No newline at end of file diff --git a/project/cafeteria/src/cafeteria/productos/alimento/FlorDeLuna.java b/project/cafeteria/src/cafeteria/productos/alimento/FlorDeLuna.java new file mode 100755 index 0000000..ed04c1b --- /dev/null +++ b/project/cafeteria/src/cafeteria/productos/alimento/FlorDeLuna.java @@ -0,0 +1,10 @@ +package cafeteria.productos.alimento; + +import cafeteria.productos.Gastronomia; +import cafeteria.productos.Gastronomia.GastronomiaTypo; + +public class FlorDeLuna extends Gastronomia { + public FlorDeLuna(int id, int cantidad, float precio) { + super(id, "Flor De Luna", cantidad, precio, GastronomiaTypo.ALIMENTO, "Una galleta aflorada con una luna en medio"); + } +} \ No newline at end of file diff --git a/project/cafeteria/src/cafeteria/productos/alimento/GalletaDorada.java b/project/cafeteria/src/cafeteria/productos/alimento/GalletaDorada.java new file mode 100755 index 0000000..6a126bf --- /dev/null +++ b/project/cafeteria/src/cafeteria/productos/alimento/GalletaDorada.java @@ -0,0 +1,10 @@ +package cafeteria.productos.alimento; + +import cafeteria.productos.Gastronomia; +import cafeteria.productos.Gastronomia.GastronomiaTypo; + +public class GalletaDorada extends Gastronomia { + public GalletaDorada(int id, int cantidad, float precio) { + super(id, "Galleta Dorada", cantidad, precio, GastronomiaTypo.ALIMENTO, "Galleta dorada (Dictan aquellos capaces de saborearla que sabe a alegría pura)"); + } +} \ No newline at end of file diff --git a/project/cafeteria/src/cafeteria/productos/alimento/GalletaRoja.java b/project/cafeteria/src/cafeteria/productos/alimento/GalletaRoja.java new file mode 100755 index 0000000..6476a95 --- /dev/null +++ b/project/cafeteria/src/cafeteria/productos/alimento/GalletaRoja.java @@ -0,0 +1,10 @@ +package cafeteria.productos.alimento; + +import cafeteria.productos.Gastronomia; +import cafeteria.productos.Gastronomia.GastronomiaTypo; + +public class GalletaRoja extends Gastronomia { + public GalletaRoja(int id, int cantidad, float precio) { + super(id, "Galleta Roja", cantidad, precio, GastronomiaTypo.ALIMENTO, "Galleta con relleno dulce, al masticarlo el relleno sale como si fuera sangre, sangre dulce"); + } +} \ No newline at end of file diff --git a/project/cafeteria/src/cafeteria/productos/alimento/PanDulce.java b/project/cafeteria/src/cafeteria/productos/alimento/PanDulce.java new file mode 100755 index 0000000..651c70c --- /dev/null +++ b/project/cafeteria/src/cafeteria/productos/alimento/PanDulce.java @@ -0,0 +1,10 @@ +package cafeteria.productos.alimento; + +import cafeteria.productos.Gastronomia; +import cafeteria.productos.Gastronomia.GastronomiaTypo; + +public class PanDulce extends Gastronomia { + public PanDulce(int id, int cantidad, float precio) { + super(id, "Pan dulce", cantidad, precio, GastronomiaTypo.ALIMENTO, "Pan dulce... solo un pan dulce"); + } +} \ No newline at end of file diff --git a/project/cafeteria/src/cafeteria/productos/bebida/CafeConLeche.java b/project/cafeteria/src/cafeteria/productos/bebida/CafeConLeche.java new file mode 100755 index 0000000..747bf2a --- /dev/null +++ b/project/cafeteria/src/cafeteria/productos/bebida/CafeConLeche.java @@ -0,0 +1,10 @@ +package cafeteria.productos.bebida; + +import cafeteria.productos.Gastronomia; +import cafeteria.productos.Gastronomia.GastronomiaTypo; + +public class CafeConLeche extends Gastronomia { + public CafeConLeche(int id, int cantidad, float precio) { + super(id, "Cafe Con Leche", cantidad, precio, GastronomiaTypo.BEBIDA, "Un simple cafe con leche"); + } +} diff --git a/project/cafeteria/src/cafeteria/productos/bebida/CafeNegro.java b/project/cafeteria/src/cafeteria/productos/bebida/CafeNegro.java new file mode 100755 index 0000000..1d2f509 --- /dev/null +++ b/project/cafeteria/src/cafeteria/productos/bebida/CafeNegro.java @@ -0,0 +1,10 @@ +package cafeteria.productos.bebida; + +import cafeteria.productos.Gastronomia; +import cafeteria.productos.Gastronomia.GastronomiaTypo; + +public class CafeNegro extends Gastronomia { + public CafeNegro(int id, int cantidad, float precio) { + super(id, "Cafe negro", cantidad, precio, GastronomiaTypo.BEBIDA, "Un simple cafe negro (Las leyendas dictan que el reflejo del cafe predice tu futuro)"); + } +} diff --git a/project/cafeteria/src/cafeteria/productos/bebida/Limonada.java b/project/cafeteria/src/cafeteria/productos/bebida/Limonada.java new file mode 100755 index 0000000..6415d95 --- /dev/null +++ b/project/cafeteria/src/cafeteria/productos/bebida/Limonada.java @@ -0,0 +1,10 @@ +package cafeteria.productos.bebida; + +import cafeteria.productos.Gastronomia; +import cafeteria.productos.Gastronomia.GastronomiaTypo; + +public class Limonada extends Gastronomia { + public Limonada(int id, int cantidad, float precio) { + super(id, "Limonada", cantidad, precio, GastronomiaTypo.BEBIDA, "Limonada dulce"); + } +} diff --git a/project/enjambre_de_langosta/META-INF/MANIFEST.MF b/project/enjambre_de_langosta/META-INF/MANIFEST.MF new file mode 100644 index 0000000..a51079e --- /dev/null +++ b/project/enjambre_de_langosta/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Main-Class: com.src.Proy1 +Created-By: Tuzikuz diff --git a/project/enjambre_de_langosta/META-INF/manifest.txt b/project/enjambre_de_langosta/META-INF/manifest.txt new file mode 100644 index 0000000..a51079e --- /dev/null +++ b/project/enjambre_de_langosta/META-INF/manifest.txt @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Main-Class: com.src.Proy1 +Created-By: Tuzikuz diff --git a/project/enjambre_de_langosta/README.md b/project/enjambre_de_langosta/README.md new file mode 100755 index 0000000..fd8b884 --- /dev/null +++ b/project/enjambre_de_langosta/README.md @@ -0,0 +1 @@ +# Proy 1 Enjambre de Langosta v1.5 \ No newline at end of file diff --git a/project/enjambre_de_langosta/build/Ault_977_Proy1.jar b/project/enjambre_de_langosta/build/Ault_977_Proy1.jar new file mode 100644 index 0000000000000000000000000000000000000000..6600d11e2bc6a42365a4ce09a8c942901370b7f7 GIT binary patch literal 11946 zcma)?1yEhtvWD^C?h@SH-QAtwaFF2c8iKnAcMh(>-5r9vyA#|cFS&Eyo6OXmTdz;; zs(osAFX^@Z-n(jjO0wV(=pfM0&>%yJ*V-Vz84L&nh`hL(Fuk;b1moKX2naZclI%O^ zUmjrpc2oMtVDz6J{}(JTtRO8RuByf$FL5nDHYz7e&oG4`OHVUCHc_j>G|RfVcO^eI zHsdlbO~=rnA~ilSN6R2H??m^FI;@e6GX{xjq>62K&yhh!o=#eR%B8eU1$ttLZdkTL z4WwjiZ+j2yUjuv8ks$u?v)fn}4<|?Ce|i1q z?BM_ACG2ADY{1RQX`tk2=fTWiYz=U7vQY-e_821j>T_mRrWRUQXlX-ePaY-&Qivf# zRxWGGVtpda;4Yz2dd74p-^LS5fNe3GWcOgc$LokeBNM7Xov(y3QR9 z8Mq*Fp!A|^>oMdR2`OYZCk~|6r<2XtllRHh!?7H?Is~4~Sy7`zSDsYP>CouYmT9s)~|%svnH{4--lSooJQYK9<027f=90w{%~OcGS&&c zgfGs073ppN3HDBkFqpn3w~CBpQQ{3xJAlb5&c{D76t)Ul4!PAs_}Dd^{mjt+me3cB zL<>f_#WcLdgh;i3DPiLg;@58UFXj+31_c4Z{kbLoc}agQx{aO5e_2l4e|t#VS~!!5 z+q&3@TLNs198LdNOczxvRa9kc-=r0W6K0M!2up2==A5uEuHYD~YVkR#^mv6GbWPk$ z)noP!PxA&e8Pb$R0~4>sh4=UxMqo>+*H?Vc83*kdwVgj+9v}?~Ja8CbcIux1e8$N- zadm5z1+*V47OP)kHvtztl)|oDFbPY5We6-+1_nL~S1#w@Zw%uASS*8mf>)It+|2D4j`sGdLOEV!+$Y$GvsUH#tl6 zfb?b1+V^_=JY#V_mrjqPC6WwLt`{*5oBohf*z=MEj{d4(q5#ju zeAov=8Jxj&)~EHpp4xY2Xi8Rq+B*IRX0Av0OOY$nJ%J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x3lcY+>#6|G>Wf@RJ1Cn2NYKJKNd*aXKolFpAi%gr1SlSgO`D--8JE3Q8vhje=*i zaU7+4M4Eg1Kt~%Egmj_2T}O<`dN7u8aPsO7hMn^<52WAEQaC`N_R9qD45IFjHL5?P}L{ zKLRI=qL7M|A-TmLm-?=F^w=+`*ny~WMQo@GUeI9=dkCtl zeTW!(@?Dl(Q(C67xDz$_sxVw?&+`Q|EMmxlXM>9=9Hz;soTl9VSNe2rXifvq@m-G-ORt5>**Kw9fh01B<>n@$#|EV zbOQUR_y<#ZpL6IE$;b2*2A(>I*Hznlq+eN=gT)JC`3WPo{k)W9LBY^L{z_H-JfQ!V z{UU4sYX67I{^D%^9{M}j`iram)A)bh{$J>Cl+D`JcCc;IRK3@e7Fk z(;j}_{)xx_b&|i+n7;toKkfa`l>Behf5K(||05p#nZ-X?&cF8kJJ9xv=KRyn{vGk3 z+0MUb`*#}X7ykCAK|uY{^WWR~6NdYHTfbu&zxbg)4GHFNZT(IY{k@srYu+!0<4>E0 z`?Hxpl>6Tj`Kv1aX>C-0#QtxM{A)UYuONR-=k8zP{$4ZxKK9==@vGkaY1`Dl_y2qK YQIduHnQ9Oagr7e?a1anp+F$?v2dce0@c;k- literal 0 HcmV?d00001 diff --git a/project/enjambre_de_langosta/makefile b/project/enjambre_de_langosta/makefile new file mode 100755 index 0000000..9c43982 --- /dev/null +++ b/project/enjambre_de_langosta/makefile @@ -0,0 +1,15 @@ +MAIN_CLASS = Proy1 + +all: + mkdir -p out + javac -d out $(shell find src -name "*.java") + cat META-INF/manifest.txt > META-INF/MANIFEST.MF + jar cfm build/$(MAIN_CLASS).jar META-INF/MANIFEST.MF -C out . + rm -rf ./out + cd build && java -jar $(MAIN_CLASS).jar + +purge_windows: + powershell -Command "Get-ChildItem -Recurse -Include *.class,*.log,*.tmp,*~ | Remove-Item -Force" + +purge_linux: + find . -name "*.class" -type f -delete \ No newline at end of file diff --git a/project/enjambre_de_langosta/src/com/Proy1.java b/project/enjambre_de_langosta/src/com/Proy1.java new file mode 100755 index 0000000..8be4810 --- /dev/null +++ b/project/enjambre_de_langosta/src/com/Proy1.java @@ -0,0 +1,11 @@ +package com.src; + +import mod.Init; + +public class Proy1 { + public static void main(String[] args) { + System.out.printf("Proy1 %n"); + Init game = new Init(); + game.start(); + } +} \ No newline at end of file diff --git a/project/enjambre_de_langosta/src/com/mod/Init.java b/project/enjambre_de_langosta/src/com/mod/Init.java new file mode 100755 index 0000000..2e8fefb --- /dev/null +++ b/project/enjambre_de_langosta/src/com/mod/Init.java @@ -0,0 +1,1123 @@ +package mod; + +import mod.utils.Vec2x2; +import mod.utils.GameButton; + + +import java.awt.Color; +import java.awt.Component; +import java.awt.Font; +import java.awt.Insets; + +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JButton; +import javax.swing.JTextField; +import javax.swing.JComponent; + + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import java.util.Random; + + + + + +public class Init extends JFrame implements ActionListener { + private JFrame window_main; + private String window_main_name = "Proy1 Ejambre de Langostas"; + + private Random rnd = new Random(); + private int ejambre = -1; + + private boolean debug = false; + private boolean debug_game_inside = false; + private JButton btn_loc_start; + private int intentos_counter = 0; + + enum EnumUIMenu { + EjambreUbication, + Debug, + Intentos, + InfoEjambre, + Iniciar + } + private JComponent[] ArrMenu = new JComponent[5]; + + private Color[] arr_color = { + Color.RED, + Color.YELLOW, + Color.GRAY, + Color.PINK, + Color.ORANGE, + Color.MAGENTA, + Color.CYAN, + new Color(190, 0, 190) + }; + + enum EnumEjambreMove { + Norte, + NorEste, + Este, + SurEste, + Sur, + SurOeste, + Oeste, + NorOeste, + } + + enum EnumEjambre { + Ejambre, + Norte, + NorEste, + Este, + SurEste, + Sur, + SurOeste, + Oeste, + NorOeste, + } + private JComponent[] ArrEjambre = new JComponent[9]; + public Init() {} + + public void start() { + System.out.printf("=====Cultivos Start Game=====\n"); + // System.out.printf("%d%n", ejambre); + + window_main = new JFrame(window_main_name); + window_main.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + window_main.setExtendedState(JFrame.MAXIMIZED_BOTH); + window_main.setLayout(null); + + Vec2x2 vec2x2_window_main = new Vec2x2(); + // vec2x2_window_main.x1_pos = 0; + // vec2x2_window_main.y1_pos = 0; + vec2x2_window_main.x2_size = 1400; + vec2x2_window_main.y2_size = 900; + + window_main.setBounds( + vec2x2_window_main.x1_pos, + vec2x2_window_main.y1_pos, + vec2x2_window_main.x2_size, + vec2x2_window_main.y2_size + ); + + + Vec2x2 vec2x2_map = new Vec2x2(); + vec2x2_map.x1_pos = 113; + vec2x2_map.y1_pos = 40; + vec2x2_map.x2_size = 0; + vec2x2_map.y2_size = 0; + + int i = 156, p = -1, x = 1, y = 14; + + // System.out.printf("Debug"); + for(; i >= 1; i = i - 1) { + p = p + 1; + + GameButton btn = new GameButton(); + btn.setEnabled(false); + btn.setText(String.valueOf(i)); + btn.setBounds( + // vec2x2_map.x1_pos+60*(p/13), + vec2x2_map.x1_pos+59*(p/13), + // vec2x2_map.y1_pos+45*(p%13), + vec2x2_map.y1_pos+45*(p%13), + 60, + 45 + ); + + // btn.setBounds(60+25*(i/13),60+55*(i%13),60,30); + // btn.setFont(new Font("Arial", Font.BOLD, 12)); + // btn.setFont(new Font("Arial", Font.BOLD, 24)); + // btn.setFont(new Font("Arial", Font.PLAIN, 18)); + btn.setMargin(new Insets(0, 0, 0, 0)); + // btn.setFont(new Font("Arial", Font.PLAIN, 16)); + btn.setFont(new Font("Arial", Font.PLAIN, 12)); + btn.addActionListener(this); + // btn.y = y; + // btn.x = x; + + window_main.add(btn); + } + + for (Component cmp : window_main.getContentPane().getComponents()) { + if (cmp instanceof GameButton) { + GameButton fiel = (GameButton) cmp; + y = y - 1; + + fiel.y = y; + fiel.x = x; + + if (y == 1) { + y = 14; + x = x + 1; + } + } + } + + + Vec2x2 vec2x2_x_label = new Vec2x2(); + // vec2x2_x_label.x1_pos = 500; + vec2x2_x_label.y1_pos = 620; + vec2x2_x_label.x2_size = 20; + vec2x2_x_label.y2_size = 28; + + int y_pos = 14, p_pos = 0, x_pos = 0; + while (true) { + x_pos = x_pos + 1; + p_pos = p_pos + 1; + // System.out.printf("y:%d p:%d %n", x_pos, y_pos, p_pos); + + vec2x2_x_label.x1_pos = 84 + p_pos * 58; + JLabel x_label = new JLabel(String.valueOf(x_pos)); + if (debug) { + x_label.setOpaque(true); + x_label.setBackground(Color.GREEN); + } + x_label.setBounds( + vec2x2_x_label.x1_pos, + vec2x2_x_label.y1_pos, + vec2x2_x_label.x2_size, + vec2x2_x_label.y2_size + ); + window_main.add(x_label); + + if (x_pos == 12) { + p_pos = 0; + break; + } + } + + Vec2x2 vec2x2_y_label = new Vec2x2(); + vec2x2_y_label.x1_pos = 80; + vec2x2_y_label.y1_pos = 0; + vec2x2_y_label.x2_size = 30; + vec2x2_y_label.y2_size = 40; + while (true) { + y_pos = y_pos - 1; + p_pos = p_pos + 1; + + vec2x2_y_label.y1_pos = 7 + p_pos * 44; + JLabel y_label = new JLabel(String.valueOf(y_pos)); + if (debug) { + y_label.setOpaque(true); + y_label.setBackground(Color.YELLOW); + } + y_label.setBounds( + vec2x2_y_label.x1_pos, + vec2x2_y_label.y1_pos, + vec2x2_y_label.x2_size, + vec2x2_y_label.y2_size + ); + window_main.add(y_label); + + if (y_pos == 1) { + break; + } + } + + + + String[] arr_cardinal = new String[] { + " Norte ", + " Este ", + " Sur ", + " Oeste ", + }; + + Vec2x2[] arr_cardinal_pos = { + new Vec2x2(440, 0, 60, 35), + new Vec2x2(823, 320, 45, 35), + new Vec2x2(440, 650, 60, 35), + new Vec2x2(15, 320, 60, 35) + }; + + int num_cardinal_pos = -1; + for(String cardinal : arr_cardinal) { + num_cardinal_pos = num_cardinal_pos + 1; + + JLabel label_cardinal = new JLabel(cardinal); + + if (debug) { + label_cardinal.setOpaque(true); + label_cardinal.setBackground(Color.BLUE); + } + + Vec2x2 vec_cardinal = arr_cardinal_pos[num_cardinal_pos]; + + // System.out.printf("Pos:%d%n", arr_cardinal_pos[num_cardinal_pos].x1_pos); + // System.out.printf("Cardinal:%d%n", num_cardinal_pos); + // System.out.printf("Vec:%d%n", vec_cardinal.x1_pos); + + label_cardinal.setBounds( + vec_cardinal.x1_pos, + vec_cardinal.y1_pos, + vec_cardinal.x2_size, + vec_cardinal.y2_size + ); + + window_main.add(label_cardinal); + } + + + Vec2x2 vec2x2_menu_info_label = new Vec2x2(); + vec2x2_menu_info_label.x1_pos = 1045; + // vec2x2_menu_info_label.y1_pos = 100; + vec2x2_menu_info_label.x2_size = 320; + vec2x2_menu_info_label.y2_size = 30; + String[] arr_infos_menu_context = new String[] { + // String.format(" %40s %s %-10s ", "Facultad de Ingeniería de Sistemas Computacionales", ":", "Universidad Facultad"), + String.format(" %50s ", "Universidad Facultad"), + String.format(" %50s ", "Facultad de Ingeniería de Sistemas Computacionales"), + String.format(" %50s ", "Carrera"), + String.format(" %50s ", "Licenciatura en Desarrollo y Gestión de Software"), + String.format(" %50s ", "Materia"), + String.format(" %50s ", "Desarrollo de Software 3"), + String.format(" %50s ", "Profesor"), + String.format(" %50s ", "Ricardo Chan"), + String.format(" %50s ", "Estudiante Cedula"), + String.format(" %50s ", "0-000-0000"), + String.format(" %50s ", "Grupo" ), + String.format(" %50s ", "\\\\[!G_G???]// Grupo de 1: Tuzikuz"), + String.format(" %50s ", "Fecha"), + String.format(" %50s ", "6/04/2025"), + }; + + + int index = -1; + // for (int index = 0; index < arr_infos_menu.length; index++) { + for (String info : arr_infos_menu_context) { + index = index + 1; + JLabel info_menu = new JLabel(arr_infos_menu_context[index]); + + + if (debug) { + info_menu.setOpaque(true); + info_menu.setBackground(Color.RED); + } + + if (index % 2 == 0) { + int index_pos = 30 + index * 40; + info_menu.setBounds( + vec2x2_menu_info_label.x1_pos, + vec2x2_menu_info_label.y1_pos + index_pos, + vec2x2_menu_info_label.x2_size, + vec2x2_menu_info_label.y2_size + ); + } else { + int index_pos = 30 + index * 40; + info_menu.setBounds( + vec2x2_menu_info_label.x1_pos, + vec2x2_menu_info_label.y1_pos + index_pos - 20, + vec2x2_menu_info_label.x2_size, + vec2x2_menu_info_label.y2_size + ); + } + + window_main.add(info_menu); + } + + + + + String[] arr_menu_game = new String[] { + // Text Field + String.format(" %s ", "None :Ejambre Ubicacion"), + // Button + String.format(" %s ", "Debug"), + // Label + String.format(" %s %s ", "None", ":Intentos"), + String.format(" %s %s ", "None", ":Ejambre"), + // Button + String.format(" %s ", "Start"), + }; + + String[] arr_menu_info = new String[] { + "Menu_Ejambre", + "Menu_Debug", + "Menu_Intentos", + "Menu_Ejambre_Info", + "Menu_Inicio", + }; + + Vec2x2 vec2x2_menu_game = new Vec2x2(); + vec2x2_menu_game.x1_pos = 872; + vec2x2_menu_game.y1_pos = 50; + vec2x2_menu_game.x2_size = 170; + vec2x2_menu_game.y2_size = 50; + + Color debug_game_menu = Color.CYAN; + int num_game_menu = -1; + while(true) { + num_game_menu = num_game_menu + 1; + vec2x2_menu_game.y1_pos = vec2x2_menu_game.y1_pos + 60; + switch (num_game_menu) { + case 0: + JTextField text_field_Ejambre_Ubicacion = new JTextField(arr_menu_game[num_game_menu]); + text_field_Ejambre_Ubicacion.setName(arr_menu_info[num_game_menu]); + if (debug) {text_field_Ejambre_Ubicacion.setBackground(debug_game_menu);} + + text_field_Ejambre_Ubicacion.setVisible(false); + + text_field_Ejambre_Ubicacion.setBounds( + vec2x2_menu_game.x1_pos, + vec2x2_menu_game.y1_pos, + vec2x2_menu_game.x2_size, + vec2x2_menu_game.y2_size + ); + text_field_Ejambre_Ubicacion.addActionListener(this); + window_main.add(text_field_Ejambre_Ubicacion); + + ArrMenu[EnumUIMenu.EjambreUbication.ordinal()] = text_field_Ejambre_Ubicacion; + break; + + case 1: + JButton button_debug = new JButton(arr_menu_game[num_game_menu]); + button_debug.setName(arr_menu_info[num_game_menu]); + if (debug) {button_debug.setBackground(debug_game_menu);} + button_debug.setEnabled(false); + + button_debug.setBounds( + vec2x2_menu_game.x1_pos, + vec2x2_menu_game.y1_pos, + vec2x2_menu_game.x2_size, + vec2x2_menu_game.y2_size + ); + button_debug.addActionListener(this); + window_main.add(button_debug); + ArrMenu[EnumUIMenu.Debug.ordinal()] = button_debug; + break; + + case 2: + JLabel button_intentoss = new JLabel(arr_menu_game[num_game_menu]); + button_intentoss.setName(arr_menu_info[num_game_menu]); + if (debug) { + button_intentoss.setBackground(debug_game_menu); + } + button_intentoss.setBounds( + vec2x2_menu_game.x1_pos, + vec2x2_menu_game.y1_pos, + vec2x2_menu_game.x2_size, + vec2x2_menu_game.y2_size + ); + window_main.add(button_intentoss); + ArrMenu[EnumUIMenu.Intentos.ordinal()] = button_intentoss; + break; + + case 3: + JLabel label_ejambre_info = new JLabel(arr_menu_game[num_game_menu]); + label_ejambre_info.setName(arr_menu_info[num_game_menu]); + if (debug) {label_ejambre_info.setBackground(debug_game_menu);} + + label_ejambre_info.setBounds( + vec2x2_menu_game.x1_pos, + vec2x2_menu_game.y1_pos, + vec2x2_menu_game.x2_size, + vec2x2_menu_game.y2_size + ); + window_main.add(label_ejambre_info); + ArrMenu[EnumUIMenu.InfoEjambre.ordinal()] = label_ejambre_info; + break; + + case 4: + JButton button_inicio = new JButton(arr_menu_game[num_game_menu]); + button_inicio.setName(arr_menu_info[num_game_menu]); + if (debug) {button_inicio.setBackground(debug_game_menu);} + + button_inicio.setBounds( + vec2x2_menu_game.x1_pos, + vec2x2_menu_game.y1_pos, + vec2x2_menu_game.x2_size, + vec2x2_menu_game.y2_size + ); + button_inicio.addActionListener(this); + window_main.add(button_inicio); + ArrMenu[EnumUIMenu.Iniciar.ordinal()] = button_inicio; + break; + default: + break; + } + if (num_game_menu == arr_menu_game.length || num_game_menu == arr_menu_info.length) { + break; + } + } + + + window_main.setVisible(true); + } + + + // public void old_ejambre_move(EnumEjambreMove move) { + // // boolean berrk = false; + // // GameButton ejambre_button = ((GameButton) ArrEjambre[EnumEjambre.Ejambre.ordinal()]); + + // // reset_point(); + // // set_point(); + + // // while (true) { + // // int next_ejambre = rnd.nextInt(156); + + // // if (next_ejambre == ejambre) { + // // continue; + // // } + + // // System.out.printf("Random Debug::::%d%n", next_ejambre); + + // // switch (move) { + // // case EnumEjambreMove.Norte: + // // break; + + // // case EnumEjambreMove.NorEste: + // // break; + + // // case EnumEjambreMove.Este: + // // break; + + // // case EnumEjambreMove.SurEste: + // // break; + + // // case EnumEjambreMove.Sur: + // // break; + + // // case EnumEjambreMove.SurOeste: + // // break; + + // // case EnumEjambreMove.Oeste: + // // for (Component cmp : window_main.getContentPane().getComponents()) { + // // if (cmp instanceof GameButton) { + // // GameButton field = (GameButton) cmp; + // // GameButton ejambre_button = ((GameButton) ArrEjambre[EnumEjambre.Ejambre.ordinal()]); + + // // if ( + // // ejambre_button.x == 1 || + // // ejambre_button.x == 12 || + // // ejambre_button.y == 1 || + // // ejambre_button.y == 13 + // // ) { + // // berrk = true; + // // break; + // // } + + // // // if (ejambre_button.x == 12) + // // // && next_ejambre < ejambre_button + // // if ( + // // Integer.parseInt(field.getText()) == next_ejambre + // // && ejambre_button.x == field.x + // // && ejambre_button.y > field.y + // // ) { + // // ejambre = next_ejambre; + + // // reset_point(); + // // ((JTextField) ArrMenu[EnumUIMenu.EjambreUbication.ordinal()]).setText(String.valueOf(ejambre)); + // // berrk = true; + // // } + // // } + // // } + // // break; + + // // case EnumEjambreMove.NorOeste: + // // break; + + // // default: + // // break; + // // } + + // // if (berrk == true) { + // // berrk = false; + // // break; + // // } + + // // } + // } + + public void actionPerformed(ActionEvent e) { + Object source = e.getSource(); + + + if (source instanceof GameButton) { + GameButton click_button = (GameButton) source; + + intentos_counter = intentos_counter + 1; + ((JLabel) ArrMenu[EnumUIMenu.Intentos.ordinal()]).setText(String.format("%d %s", intentos_counter, ":Intentos")); + + System.out.printf("%s:(x:%d,y:%d)%n", click_button.getText(), click_button.x, click_button.y); + + if (ejambre == Integer.parseInt(click_button.getText())) { + // ! Ganar + ((JLabel) ArrMenu[EnumUIMenu.InfoEjambre.ordinal()]).setText(String.format(" %s ", "Ganastes \\wuw/")); + + ((JButton) ArrMenu[EnumUIMenu.Iniciar.ordinal()]).setEnabled(true); + ((JButton) ArrMenu[EnumUIMenu.Debug.ordinal()]).setEnabled(false); + ((JTextField) ArrMenu[EnumUIMenu.EjambreUbication.ordinal()]).setVisible(false); + + set_purge_point(); + + for (Component cmp : window_main.getContentPane().getComponents()) { + if (cmp instanceof GameButton) { + GameButton fiel = (GameButton) cmp; + fiel.setEnabled(false); + } + } + } + + + // click_button.x, click_button.y + // if (click_button.x == click_button.y) ( + + GameButton btn_ejambre = ((GameButton) ArrEjambre[EnumEjambre.Ejambre.ordinal()]); + // System.out.printf("%d", click_button.x); + // System.out.printf("%d", btn_ejambre.x); + if ( + // Corre ejambre 1 + click_button.x == btn_ejambre.x && click_button.y == btn_ejambre.y + 1 || + // Corre ejambre 2 + click_button.x == btn_ejambre.x + 1 && click_button.y == btn_ejambre.y + 1 || + // Corre ejambre 3 + click_button.x == btn_ejambre.x + 1 && click_button.y == btn_ejambre.y || + // Corre ejambre 4 + click_button.x == btn_ejambre.x + 1 && click_button.y == btn_ejambre.y - 1 || + // Corre ejambre 5 + click_button.x == btn_ejambre.x && click_button.y == btn_ejambre.y - 1 || + // Corre ejambre 6 + click_button.x == btn_ejambre.x - 1 && click_button.y == btn_ejambre.y - 1 || + // Corre ejambre 7 + click_button.x == btn_ejambre.x - 1 && click_button.y == btn_ejambre.y || + // Corre ejambre 8 + click_button.x == btn_ejambre.x - 1 && click_button.y == btn_ejambre.y + 1 + + ) { + ((JLabel) ArrMenu[EnumUIMenu.InfoEjambre.ordinal()]).setText(String.format("Se escapo el ejambre T-T")); + // ! Corre ejambre + + set_new_enjambre_ubication(); + return; + } + + // * ! Sur =! Norte + if (click_button.x == btn_ejambre.x && click_button.y <= btn_ejambre.y - 2) { + ((JLabel) ArrMenu[EnumUIMenu.InfoEjambre.ordinal()]).setText(String.format("Por el Norte :EJambre")); + return; + } + + // * SurOeste != NorEste + if ( + click_button.x <= btn_ejambre.x - 2 && + click_button.y <= btn_ejambre.y - 2 || + click_button.x <= btn_ejambre.x - 2 && + click_button.y <= btn_ejambre.y - 1 || + click_button.x <= btn_ejambre.x - 1 && + click_button.y <= btn_ejambre.y - 2 + ) { + // System.out.printf("%n%d%n", btn_ejambre.x); + ((JLabel) ArrMenu[EnumUIMenu.InfoEjambre.ordinal()]).setText(String.format("Por el NorEste :EJambre")); + return; + } + + // * ! Oeste =! Este + if (click_button.x <= btn_ejambre.x - 2 && click_button.y == btn_ejambre.y) { + ((JLabel) ArrMenu[EnumUIMenu.InfoEjambre.ordinal()]).setText(String.format("Por el Este :EJambre")); + return; + } + + // * SurEste != NorOeste + if ( + click_button.x >= btn_ejambre.x + 2 && + click_button.y <= btn_ejambre.y - 2 || + + click_button.x <= btn_ejambre.x + 2 && + click_button.y <= btn_ejambre.y - 1 || + + click_button.x <= btn_ejambre.x + 1 && + click_button.y <= btn_ejambre.y - 2 + + // click_button.x >= btn_ejambre.x - 2 && click_button.y <= btn_ejambre.y - 2 + ) { + // System.out.printf("%n%d%n", btn_ejambre.x); + ((JLabel) ArrMenu[EnumUIMenu.InfoEjambre.ordinal()]).setText(String.format("Por el NorOeste :EJambre")); + return; + } + + // * ! Norte != Sur + if (click_button.x == btn_ejambre.x && click_button.y >= btn_ejambre.y + 2) { + ((JLabel) ArrMenu[EnumUIMenu.InfoEjambre.ordinal()]).setText(String.format("Por el Sur :EJambre")); + return; + } + + + // * ! NorEste != SurOeste + if ( + click_button.x >= btn_ejambre.x + 2 && + click_button.y >= btn_ejambre.y + 2 || + + click_button.x >= btn_ejambre.x + 2 && + click_button.y >= btn_ejambre.y + 1 || + + click_button.x >= btn_ejambre.x + 1 && + click_button.y >= btn_ejambre.y + 2 + + // click_button.x <= btn_ejambre.x - 2 && click_button.y >= btn_ejambre.y - 2 + ) { + // System.out.printf("%n%d%n", btn_ejambre.x); + ((JLabel) ArrMenu[EnumUIMenu.InfoEjambre.ordinal()]).setText(String.format("Por el SurOeste :EJambre")); + // ((JLabel) ArrMenu[EnumUIMenu.InfoEjambre.ordinal()]).setText(String.format("Chacha :EJambre")); + return; + } + + // * ! Este != Oeste + if (click_button.x >= btn_ejambre.x + 2 && click_button.y == btn_ejambre.y) { + ((JLabel) ArrMenu[EnumUIMenu.InfoEjambre.ordinal()]).setText(String.format("Por el Oeste :EJambre")); + return; + } + + // * ! NorOeste != SurEste + if ( + click_button.x <= btn_ejambre.x - 2 && + click_button.y >= btn_ejambre.y + 2 || + + click_button.x <= btn_ejambre.x - 2 && + click_button.y >= btn_ejambre.y + 1 || + + click_button.x <= btn_ejambre.x - 1 && + click_button.y >= btn_ejambre.y + 2 + + // click_button.x >= btn_ejambre.x + 2 && click_button.y >= btn_ejambre.y + 2 + ) { + // System.out.printf("%n%d%n", btn_ejambre.x); + ((JLabel) ArrMenu[EnumUIMenu.InfoEjambre.ordinal()]).setText(String.format("Por el SurEste :EJambre")); + // ((JLabel) ArrMenu[EnumUIMenu.InfoEjambre.ordinal()]).setText(String.format("Chacha :EJambre")); + return; + } + + + return; + } + + if (source instanceof JButton) { + JButton button_get = (JButton) source; + switch (button_get.getName()) { + case "Menu_Debug": + if (debug_game_inside == false) { + set_color_debug_true(); + break; + } + + if (debug_game_inside == true) { + set_color_debug_false(); + break; + } + + break; + case "Menu_Inicio": + + intentos_counter = 0; + + ((JLabel) ArrMenu[EnumUIMenu.Intentos.ordinal()]).setText(String.format(" %d %s ", intentos_counter, ":Intentos")); + + ((JLabel) ArrMenu[EnumUIMenu.InfoEjambre.ordinal()]).setText(String.format(" %s %s ", "None", ":Ejambre")); + + + ejambre = rnd.nextInt(156); + ((JTextField) ArrMenu[EnumUIMenu.EjambreUbication.ordinal()]).setText(String.valueOf(ejambre)); + ((JTextField) ArrMenu[EnumUIMenu.EjambreUbication.ordinal()]).setVisible(false); + + button_get.setEnabled(false); + debug_game_inside = false; + ((JButton) ArrMenu[EnumUIMenu.Debug.ordinal()]).setEnabled(true); + + for (Component cmp : window_main.getContentPane().getComponents()) { + if (cmp instanceof GameButton) { + GameButton fiel = (GameButton) cmp; + if (ejambre == Integer.parseInt(fiel.getText())) { + // System.out.printf("Ejambre: %s:(x:%d,y:%d)%n", fiel.getText(), fiel.x, fiel.y); + // fiel.setBackground(Color.BLUE); + ArrEjambre[EnumEjambre.Ejambre.ordinal()] = fiel; + // break; + } + + fiel.setEnabled(true); + } + } + + for (Component cmp : window_main.getContentPane().getComponents()) { + if (cmp instanceof GameButton) { + GameButton fields = (GameButton) cmp; + + int ejambre_x = ((GameButton) ArrEjambre[EnumEjambre.Ejambre.ordinal()]).x; + int ejambre_y = ((GameButton) ArrEjambre[EnumEjambre.Ejambre.ordinal()]).y; + + // Norte + if (fields.x == ejambre_x && fields.y == ejambre_y + 1) { + // fields.setBackground(Color.RED); + ArrEjambre[EnumEjambre.Norte.ordinal()] = fields; + continue; + } + // NorEste + if (fields.x == ejambre_x + 1 && fields.y == ejambre_y + 1) { + // fields.setBackground(Color.YELLOW); + ArrEjambre[EnumEjambre.NorEste.ordinal()] = fields; + continue; + } + // Este + if (fields.x == ejambre_x + 1 && fields.y == ejambre_y) { + // fields.setBackground(Color.GRAY); + ArrEjambre[EnumEjambre.Este.ordinal()] = fields; + continue; + } + // SurEste + if (fields.x == ejambre_x + 1 && fields.y == ejambre_y - 1) { + // fields.setBackground(Color.PINK); + ArrEjambre[EnumEjambre.SurEste.ordinal()] = fields; + continue; + } + // Sur + if (fields.x == ejambre_x && fields.y == ejambre_y - 1) { + // fields.setBackground(Color.ORANGE); + ArrEjambre[EnumEjambre.Sur.ordinal()] = fields; + continue; + } + // SurOeste + if (fields.x == ejambre_x - 1 && fields.y == ejambre_y - 1) { + // fields.setBackground(Color.MAGENTA); + ArrEjambre[EnumEjambre.SurOeste.ordinal()] = fields; + continue; + } + // Oeste + if (fields.x == ejambre_x - 1 && fields.y == ejambre_y) { + // fields.setBackground(Color.CYAN); + ArrEjambre[EnumEjambre.Oeste.ordinal()] = fields; + continue; + } + // Noroeste + if (fields.x == ejambre_x - 1 && fields.y == ejambre_y + 1) { + // fields.setBackground(new Color(190, 0, 190)); + ArrEjambre[EnumEjambre.NorOeste.ordinal()] = fields; + continue; + } + } + } + + // ArrMenu[EnumEjambre.Ejambre.ordinal()].setBackground(Color.Red) + // ArrMenu[EnumEjambre.Ejambre.ordinal()].setBackground(Color.YELLOW) + // fiel.getText(), fiel.x, fiel.y + // System.out.printf("Cerca EJembre: %s:(x:%d,y:%d)%n", fiel.getText(), fiel.x, fiel.y); + + // if (ejambre == Integer.parseInt(fiel.getText())) { + + // } + // fiel.setBackground(Color.RED); + + + break; + default: + break; + } + return; + } + + try { + if (source instanceof JTextField) { + System.out.printf("Debug 0%n"); + JTextField field = (JTextField) source; + + switch (field.getName()) { + case "Menu_Ejambre": + + if ( + Integer.parseInt(field.getText()) >= 156 || + Integer.parseInt(field.getText()) <= 0 + ) { + field.setText(String.format("Invalid num Ejambre = %d", ejambre)); + break; + } + + int new_number = Integer.parseInt(field.getText()); + // System.out.printf("11%n"); + System.out.printf("Debug 1%n"); + ejambre = new_number; + field.setText(String.format("Ejambre = %d", ejambre)); + + + + // reset_point(); + + // ((JTextField) ArrMenu[EnumUIMenu.EjambreUbication.ordinal()]).setVisible(false); + + // ! Set colors + set_purge_point(); + set_ejambre_points(); + set_reset_debug(); + // for (int h = 1; h <= arr_color.length; h = h + 1) { + // // System.out.printf("%d%n", h); + // if (((GameButton) ArrEjambre[h]) == null) { continue; } + // ((GameButton) ArrEjambre[h]).setBackground(arr_color[h - 1]); + // } + + break; + default: + break; + } + } + } catch (NumberFormatException ex) { + if (source instanceof JTextField) { + JTextField field = (JTextField) source; + + switch (field.getName()) { + case "Menu_Ejambre": + field.setText(String.format("%s: Ejambre = %d", "Invalid type!", ejambre)); + break; + default: + break; + } + return; + } + } + } + + public void set_point() { + // if (debug_game_inside == false) { + // ((JTextField) ArrMenu[EnumUIMenu.EjambreUbication.ordinal()]).setVisible(true); + + System.out.printf("%d%n", arr_color.length); + for (int h = 1; h <= arr_color.length; h = h + 1) { + System.out.printf("%d%n", h); + + if (((GameButton) ArrEjambre[h]) == null) { + continue; + } + ((GameButton) ArrEjambre[h]).setBackground(arr_color[h - 1]); + } + + // debug_game_inside = true; + // // break; + // } + } + + public void set_random_ejambre() { + ejambre = rnd.nextInt(156); + } + + public void set_purge_point() { + for (int h = 1; h <= arr_color.length; h = h + 1) { + if (((GameButton) ArrEjambre[h]) == null) {continue;} + ((GameButton) ArrEjambre[h]).setBackground(null); + ArrEjambre[h] = null; + } + + // debug_game_inside = false; + } + + public void set_label_ejambre() { + ((JTextField) ArrMenu[EnumUIMenu.EjambreUbication.ordinal()]).setText(String.format("%d", ejambre)); + } + + public void set_color_debug_true() { + if (debug_game_inside == false) { + ((JTextField) ArrMenu[EnumUIMenu.EjambreUbication.ordinal()]).setVisible(true); + for (int h = 1; h <= arr_color.length; h = h + 1) { + if (((GameButton) ArrEjambre[h]) == null) { continue; } + ((GameButton) ArrEjambre[h]).setBackground(arr_color[h - 1]); + } + debug_game_inside = true; + } + } + + public void set_color_debug_false() { + if (debug_game_inside == true) { + ((JTextField) ArrMenu[EnumUIMenu.EjambreUbication.ordinal()]).setVisible(false); + for (int h = 1; h <= arr_color.length; h = h + 1) { + if (((GameButton) ArrEjambre[h]) == null) { continue; } + ((GameButton) ArrEjambre[h]).setBackground(null); + } + debug_game_inside = false; + } + } + + public void set_reset_debug() { + if (debug_game_inside == true) { + for (int h = 1; h <= arr_color.length; h = h + 1) { + if (((GameButton) ArrEjambre[h]) == null) { continue; } + ((GameButton) ArrEjambre[h]).setBackground(arr_color[h - 1]); + } + } + } + + public void set_ejambre_points() { + // ! Get Ejambre + for (Component cmp : window_main.getContentPane().getComponents()) { + if (cmp instanceof GameButton) { + GameButton fiel = (GameButton) cmp; + if (ejambre == Integer.parseInt(fiel.getText())) { + ArrEjambre[EnumEjambre.Ejambre.ordinal()] = fiel; + break; + } + } + } + + // ! Get positions adyacentes + for (Component cmp : window_main.getContentPane().getComponents()) { + if (cmp instanceof GameButton) { + GameButton field = (GameButton) cmp; + + int ejambre_x = ((GameButton) ArrEjambre[EnumEjambre.Ejambre.ordinal()]).x; + int ejambre_y = ((GameButton) ArrEjambre[EnumEjambre.Ejambre.ordinal()]).y; + + // Norte + if (field.x == ejambre_x && field.y == ejambre_y + 1) { + // field.setBackground(Color.RED); + ArrEjambre[EnumEjambre.Norte.ordinal()] = field; + continue; + } + // NorEste + if (field.x == ejambre_x + 1 && field.y == ejambre_y + 1) { + // field.setBackground(Color.YELLOW); + ArrEjambre[EnumEjambre.NorEste.ordinal()] = field; + continue; + } + // Este + if (field.x == ejambre_x + 1 && field.y == ejambre_y) { + // field.setBackground(Color.GRAY); + ArrEjambre[EnumEjambre.Este.ordinal()] = field; + continue; + } + // SurEste + if (field.x == ejambre_x + 1 && field.y == ejambre_y - 1) { + // field.setBackground(Color.PINK); + ArrEjambre[EnumEjambre.SurEste.ordinal()] = field; + continue; + } + // Sur + if (field.x == ejambre_x && field.y == ejambre_y - 1) { + // field.setBackground(Color.ORANGE); + ArrEjambre[EnumEjambre.Sur.ordinal()] = field; + continue; + } + // SurOeste + if (field.x == ejambre_x - 1 && field.y == ejambre_y - 1) { + // field.setBackground(Color.MAGENTA); + ArrEjambre[EnumEjambre.SurOeste.ordinal()] = field; + continue; + } + // Oeste + if (field.x == ejambre_x - 1 && field.y == ejambre_y) { + // field.setBackground(Color.CYAN); + ArrEjambre[EnumEjambre.Oeste.ordinal()] = field; + continue; + } + // Noroeste + if (field.x == ejambre_x - 1 && field.y == ejambre_y + 1) { + // field.setBackground(new Color(190, 0, 190)); + ArrEjambre[EnumEjambre.NorOeste.ordinal()] = field; + continue; + } + } + } + } + + public void set_new_enjambre_ubication() { + set_purge_point(); + set_random_ejambre(); + set_label_ejambre(); + // ! Purge Point + // for (int h = 1; h <= arr_color.length; h = h + 1) { + // System.out.printf("%d%n", h); + + // if (((GameButton) ArrEjambre[h]) == null) {continue;} + // ((GameButton) ArrEjambre[h]).setBackground(null); + // } + + // for (int h = 1; h <= arr_color.length; h = h + 1) { + // if (((GameButton) ArrEjambre[h]) == null) {continue;} + // ((GameButton) ArrEjambre[h]).setBackground(null); + // ArrEjambre[h] = null; + // } + + set_ejambre_points(); + + System.out.printf("Debu_game_inside:%b%n", debug_game_inside); + set_reset_debug(); + } + + public void reset_point() { + for (int h = 1; h <= arr_color.length; h = h + 1) { + System.out.printf("%d%n", h); + + if (((GameButton) ArrEjambre[h]) == null) { + continue; + } + ((GameButton) ArrEjambre[h]).setBackground(null); + } + + for (Component cmp : window_main.getContentPane().getComponents()) { + if (cmp instanceof GameButton) { + GameButton fiel = (GameButton) cmp; + if (ejambre == Integer.parseInt(fiel.getText())) { + // System.out.printf("Ejambre: %s:(x:%d,y:%d)%n", fiel.getText(), fiel.x, fiel.y); + // fiel.setBackground(Color.BLUE); + ArrEjambre[EnumEjambre.Ejambre.ordinal()] = fiel; + break; + } + } + } + + for (Component cmp : window_main.getContentPane().getComponents()) { + if (cmp instanceof GameButton) { + GameButton field = (GameButton) cmp; + + int ejambre_x = ((GameButton) ArrEjambre[EnumEjambre.Ejambre.ordinal()]).x; + int ejambre_y = ((GameButton) ArrEjambre[EnumEjambre.Ejambre.ordinal()]).y; + + // Norte + if (field.x == ejambre_x && field.y == ejambre_y + 1) { + // field.setBackground(Color.RED); + ArrEjambre[EnumEjambre.Norte.ordinal()] = field; + continue; + } + // NorEste + if (field.x == ejambre_x + 1 && field.y == ejambre_y + 1) { + // field.setBackground(Color.YELLOW); + ArrEjambre[EnumEjambre.NorEste.ordinal()] = field; + continue; + } + // Este + if (field.x == ejambre_x + 1 && field.y == ejambre_y) { + // field.setBackground(Color.GRAY); + ArrEjambre[EnumEjambre.Este.ordinal()] = field; + continue; + } + // SurEste + if (field.x == ejambre_x + 1 && field.y == ejambre_y - 1) { + // field.setBackground(Color.PINK); + ArrEjambre[EnumEjambre.SurEste.ordinal()] = field; + continue; + } + // Sur + if (field.x == ejambre_x && field.y == ejambre_y - 1) { + // field.setBackground(Color.ORANGE); + ArrEjambre[EnumEjambre.Sur.ordinal()] = field; + continue; + } + // SurOeste + if (field.x == ejambre_x - 1 && field.y == ejambre_y - 1) { + // field.setBackground(Color.MAGENTA); + ArrEjambre[EnumEjambre.SurOeste.ordinal()] = field; + continue; + } + // Oeste + if (field.x == ejambre_x - 1 && field.y == ejambre_y) { + // field.setBackground(Color.CYAN); + ArrEjambre[EnumEjambre.Oeste.ordinal()] = field; + continue; + } + // Noroeste + if (field.x == ejambre_x - 1 && field.y == ejambre_y + 1) { + // field.setBackground(new Color(190, 0, 190)); + ArrEjambre[EnumEjambre.NorOeste.ordinal()] = field; + continue; + } + } + } + } +} \ No newline at end of file diff --git a/project/enjambre_de_langosta/src/com/mod/utils/GameButton.java b/project/enjambre_de_langosta/src/com/mod/utils/GameButton.java new file mode 100755 index 0000000..1163642 --- /dev/null +++ b/project/enjambre_de_langosta/src/com/mod/utils/GameButton.java @@ -0,0 +1,8 @@ +package mod.utils; + +import javax.swing.*; +import java.awt.event.*; + +public class GameButton extends JButton { + public int x, y; +} \ No newline at end of file diff --git a/project/enjambre_de_langosta/src/com/mod/utils/Vec2x2.java b/project/enjambre_de_langosta/src/com/mod/utils/Vec2x2.java new file mode 100755 index 0000000..7936128 --- /dev/null +++ b/project/enjambre_de_langosta/src/com/mod/utils/Vec2x2.java @@ -0,0 +1,27 @@ +package mod.utils; + +public class Vec2x2 { + // Position + public int x1_pos; + public int y1_pos; + + // Size + public int x2_size; + public int y2_size; + + + public Vec2x2() { + this.x1_pos = 0; + this.y1_pos = 0; + this.x2_size = 0; + this.y2_size = 0; + } + + public Vec2x2(int x1, int y1, int x2, int y2) { + this.x1_pos = x1; + this.y1_pos = y1; + this.x2_size = x2; + this.y2_size = y2; + } + +} \ No newline at end of file diff --git a/project/juego_de_adivinanza_de_numeros/Main.java b/project/juego_de_adivinanza_de_numeros/Main.java new file mode 100755 index 0000000..787b380 --- /dev/null +++ b/project/juego_de_adivinanza_de_numeros/Main.java @@ -0,0 +1,66 @@ +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.io.IOException; +import java.util.Random; + +public class Main { + public static void main(String[] args) { + InputStreamReader inputStreamReader = new InputStreamReader(System.in); + BufferedReader bufferedReader = new BufferedReader(inputStreamReader); + Random random = new Random(); + + try { + System.out.printf("Ingrese el numero maximo del juego [Adivina el numero]: "); + String inputDelUsuario = bufferedReader.readLine(); + int inputDelUsuarioToInt = Integer.parseInt(inputDelUsuario); + System.out.printf("%n"); + + + int numeroRandom = random.nextInt(inputDelUsuarioToInt) + 1; + Adivina adivina = new Adivina(numeroRandom); + adivina.jugar(); + } catch (IOException e) { + System.out.println("Ocurrio un error de entrada/salida:" + e.getMessage()); + return; + } catch (NumberFormatException e) { + System.out.println("Por favor, ingresa solo numeros validos."); + return; + } + } +} + + +class Adivina { + int index; + Adivina(int index) { + this.index = index; + } + + public void jugar() { + InputStreamReader inputStreamReader = new InputStreamReader(System.in); + BufferedReader bufferedReader = new BufferedReader(inputStreamReader); + + try { + while (true) { + System.out.printf("Adivina el numero: "); + String inputDelUsuario = bufferedReader.readLine(); + int inputDelUsuarioToInt = Integer.parseInt(inputDelUsuario); + + if (inputDelUsuarioToInt == index) { + System.out.printf("Felicidades acertastes el numero es => [%d]%n", inputDelUsuarioToInt); + break; + } + if (inputDelUsuarioToInt < index) { + System.out.printf("Incorrecto [%d] es menor.%n%n", inputDelUsuarioToInt); + continue; + } + if (inputDelUsuarioToInt > index) { + System.out.printf("Incorrecto [%d] es mayor.%n%n", inputDelUsuarioToInt); + continue; + } + } + } catch (IOException e) { + System.out.println("Ocurrio un error de entrada/salida:" + e.getMessage()); + } finally {} + } +} \ No newline at end of file diff --git a/project/juego_de_adivinanza_de_numeros/makefile b/project/juego_de_adivinanza_de_numeros/makefile new file mode 100755 index 0000000..a958afd --- /dev/null +++ b/project/juego_de_adivinanza_de_numeros/makefile @@ -0,0 +1,3 @@ +all: + javac Main.java + java Main \ No newline at end of file diff --git a/project/rompecabeza/META-INF/MANIFEST.MF b/project/rompecabeza/META-INF/MANIFEST.MF new file mode 100644 index 0000000..31ee422 --- /dev/null +++ b/project/rompecabeza/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Main-Class: com.src.Proy2 +Created-By: tuzikuz diff --git a/project/rompecabeza/META-INF/manifest.txt b/project/rompecabeza/META-INF/manifest.txt new file mode 100644 index 0000000..31ee422 --- /dev/null +++ b/project/rompecabeza/META-INF/manifest.txt @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Main-Class: com.src.Proy2 +Created-By: tuzikuz diff --git a/project/rompecabeza/Makefile b/project/rompecabeza/Makefile new file mode 100755 index 0000000..499385b --- /dev/null +++ b/project/rompecabeza/Makefile @@ -0,0 +1,15 @@ +MAIN_CLASS = Proy2 + +all: + mkdir -p out + javac -d out $(shell find src -name "*.java") + cat META-INF/manifest.txt > META-INF/MANIFEST.MF + jar cfm build/$(MAIN_CLASS).jar META-INF/MANIFEST.MF -C out . + rm -rf ./out + cd build && java -jar $(MAIN_CLASS).jar + +purge_windows: + powershell -Command "Get-ChildItem -Recurse -Include *.class,*.log,*.tmp,*~ | Remove-Item -Force" + +purge_linux: + find . -name "*.class" -type f -delete \ No newline at end of file diff --git a/project/rompecabeza/README.md b/project/rompecabeza/README.md new file mode 100644 index 0000000..017dcf6 --- /dev/null +++ b/project/rompecabeza/README.md @@ -0,0 +1,17 @@ +# Rompecabeza Proy 2 v1.0 + +## Como compilar el programa (Java) (Linux) + +### Requerimientos +- Java 17 ([adoptium](https://adoptium.net)) +- shell + + +### Comandos + +#### Make (LInux) +```shell + +make + +``` \ No newline at end of file diff --git a/project/rompecabeza/build/Proy2.jar b/project/rompecabeza/build/Proy2.jar new file mode 100644 index 0000000000000000000000000000000000000000..c595ded7720dd3ea33058f0b13a5751ebbd7d22b GIT binary patch literal 13450 zcma)j1yr3$5-#p83GVLh?(XjHc7fo*-QC^Yg9mqqph1GWdkFGiXLctu@9my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3S!+2ak z;MnX`>P3=}h#_KC7X}T|P||M30Cy!p8gKO=ZiFyR(%`JguAg*_KV9AJ-ydUlvvPf4 z*?~J?yP|+n+1s?nATfMI;SsxbYeS~c8Bwvb19MzkU+RaJ0Zon~vH>=aoA5ssBkSSF zMsNX5U)PmOUe*$bbZfHd+wAGpTeeZPom*mZ2^i7p95|V`bsJs5=K+3Z%TNTInPTzV zd{pf4Kqv^rDd5ikh7GGBzwE*q6%v2CMc56#Kg3DM`j~^z!+A)`5nTSo_*P~9Kop8Hzqx;-P=*9`3K|_iL{lmR(6`SNrBbd+uMUO~YHRwn5Mg`U31!PVVlk9!;`o3Xh zv24cKZ?A@J{gtTSh|L1p$h<_aRafuu-w}UR*C3&PL%aQ7hy#P50sXx#;f>VtFL`fE z_`Ce4&)~gDK|%WOroVRxyvOig!u$62Kc>I6D7<@s0s8Nq1b=yW8}84(g8y#u-dXUM zoV>mLtIy!CnZ6TrekZ!WcN+X9C~uJb$Lg=Xga7}DR=t7u2Rr`nL;g;4ekU{kB~yP| z{LYsD9oqK^|4z*OyEV}pRr7tke_8)|B>rjrJDKk9*41yA{m1%GD(63~f9E;96Yl;J z4%pwU|8M%;KOOyEUEgU@f5{5`UylCBb?>(SEi&Hg?_W|){fF(J)%fqI|6Y#X>+xSQ z|GU{gtMfl+{(IhjuU&u11 puzzle_buttons_vec = new Vector<>(); + + private JLabel move_show; + + + private boolean ganastes = false; + + private boolean quick_fix_debug_start = false; + + private String[] menu_game; + private Vector menu_game_buttons = new Vector<>(); + enum EnumMenuGame { + Iniciar, + Reiniciar, + Puntuacion, + IniciarDebug, + } + + private JScrollPane scroll_pane; + + private String[] menu_board; + private DefaultListModel list_default_model; + + private boolean debug_program = false; + private boolean debug_game = true; + + private JLabel crono_show; + + private Vector user_data_Vec = new Vector<>(); + private int crono = 0; + private Timer timer_crono = new Timer(1000, new ActionListener() { + + public void actionPerformed(ActionEvent e) { + crono = crono + 1; + crono_show.setText(String.format("Timer: %d", crono)); + } + }); + + private int anim_btn_vec_pos = 0; + private GameButton btn_movimiento_tmp; + private Timer timer_move_anim = new Timer(15, new ActionListener() + { + public void actionPerformed(ActionEvent e) { + boton_en_movimiento = true; + + int btn_sisi_location_x = btn_movimiento_tmp.getLocation().x; + int btn_sisi_location_y = btn_movimiento_tmp.getLocation().y; + + // if (DEBUG_CONSOLE) { + // System.out.printf("Anim X:%d Y:%d%n", btn_movimiento_tmp.x_anim, btn_movimiento_tmp.y_anim); + // System.out.printf("Loop X:%d Y:%d%n", btn_sisi_location_x, btn_sisi_location_y); + // } + + + if ( + btn_sisi_location_x == btn_movimiento_tmp.x_anim + && + btn_sisi_location_y == btn_movimiento_tmp.y_anim + ) { + boton_en_movimiento = false; + timer_move_anim.stop(); + System.out.printf("Stop timer%n"); + ganastes(); + return; + } + + + if (btn_sisi_location_x > btn_movimiento_tmp.x_anim) { + btn_movimiento_tmp.setLocation(btn_sisi_location_x - 1, btn_sisi_location_y); + return; + } + + if (btn_sisi_location_x < btn_movimiento_tmp.x_anim) { + btn_movimiento_tmp.setLocation(btn_sisi_location_x + 1, btn_sisi_location_y); + return; + } + + if (btn_sisi_location_y > btn_movimiento_tmp.y_anim) { + btn_movimiento_tmp.setLocation(btn_sisi_location_x, btn_sisi_location_y - 1); + return; + } + + if (btn_sisi_location_y < btn_movimiento_tmp.y_anim) { + btn_movimiento_tmp.setLocation(btn_sisi_location_x, btn_sisi_location_y + 1); + return; + } + } + }); + + private int button_num_clicked; + private boolean boton_en_movimiento = false; + private Timer mover_boton = new Timer(100, new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + boton_en_movimiento = true; + + int puzz_x = puzzle_buttons_vec.get(button_num_clicked).getLocation().x; + int puzz_y = puzzle_buttons_vec.get(button_num_clicked).getLocation().y; + + puzzle_buttons_vec.get(button_num_clicked).setLocation(puzz_x + 1, puzz_y + 1); + } + }); + + + public Init() { + this.setTitle("Proy2 "); + this.setLayout(null); + this.setVisible(true); + this.setBounds( + 0, + 0, + 1000, + 900 + ); + if (debug_program) { + this.getContentPane().setBackground(Color.WHITE); + } + this.setExtendedState(JFrame.MAXIMIZED_BOTH); + this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + menu_info = new String[] { + String.format(" %45s ", "Universidad Facultad"), + String.format(" %45s ", " Facultad de Ingeniería de Sistemas Computacionales"), + + String.format(" %45s ", "Carrera"), + String.format(" %45s ", " Licenciatura en Desarrollo y Gestión de Software"), + + String.format(" %45s ", "Materia"), + String.format(" %45s ", "Desarrollo de Software 3"), + + String.format(" %45s ", "Profesor"), + String.format(" %45s ", "Ricardo Chan"), + + String.format(" %45s ", "Estudiante Cedula"), + String.format(" %45s ", "0-000-0000"), + + String.format(" %45s ", "Grupo" ), + String.format(" %45s ", "Tuzikuz"), + + String.format(" %45s ", "Fecha"), + String.format(" %45s ", "????"), + }; + + + menu_game = new String[] { + String.format("Iniciar"), + String.format("Reiniciar"), + String.format("Puntuacion"), + String.format("Iniciar Debug") + }; + + menu_board = new String[] { + "Tabla", + "" + }; + } + + public void start() { + // ? ============== Menu Info + Vec2x2 vec2x2_menu_info = new Vec2x2(); + vec2x2_menu_info.x1_pos = 10; + vec2x2_menu_info.y1_pos = 25; + vec2x2_menu_info.x2_size = 355; + vec2x2_menu_info.y2_size = 30; + for (int index = 0; index < menu_info.length; index = index + 1 ) { + JLabel label_menu_info = new JLabel(menu_info[index]); + label_menu_info.setFont(new Font("Arial", Font.PLAIN, 12)); + + + if (debug_program) { + label_menu_info.setOpaque(true); + label_menu_info.setBackground(Color.RED); + } + + + if (index % 2 == 0) { + int index_pos = 30 + index * 40; + label_menu_info.setBounds( + vec2x2_menu_info.x1_pos, + vec2x2_menu_info.y1_pos + index_pos, + vec2x2_menu_info.x2_size, + vec2x2_menu_info.y2_size + ); + } else { + int index_pos = 30 + index * 40; + label_menu_info.setBounds( + vec2x2_menu_info.x1_pos, + vec2x2_menu_info.y1_pos + index_pos - 20, + vec2x2_menu_info.x2_size, + vec2x2_menu_info.y2_size + ); + } + + this.add(label_menu_info); + } + + + // ? ============== Puzzle + Vec2x2 vec2x2_puzzle = new Vec2x2(); + vec2x2_puzzle.x1_pos = 425; + vec2x2_puzzle.y1_pos = 50; + vec2x2_puzzle.x2_size = 0; + vec2x2_puzzle.y2_size = 0; + + for(int index = 0; index < puzzle_buttons_num; index = index + 1) { + GameButton button = new GameButton(); + button.setEnabled(true); + button.setText(String.valueOf(index + 1)); + button.setBounds( + vec2x2_puzzle.x1_pos+63*(index%4), + vec2x2_puzzle.y1_pos+45*(index/4), + 60, + 45 + ); + + button.setFont(new Font("Arial", Font.PLAIN, 16)); + button.addActionListener(this); + button.setEnabled(false); + this.add(button); + puzzle_buttons_vec.add(button); + } + + puzzle_buttons_vec.get(puzzle_buttons_vec.size() - 1).setVisible(false); + + int button_num_x = 0; + int button_num_y = 1; + for (Component cmp : this.getContentPane().getComponents()) { + if (cmp instanceof GameButton) { + GameButton fiel = (GameButton) cmp; + button_num_x = button_num_x + 1; + + fiel.x = button_num_x; + fiel.y = button_num_y; + + if (button_num_x == 4) { + button_num_y = button_num_y + 1; + button_num_x = 0; + } + } + } + + + // ? ============== Menu Game + Vec2x2 vec2x2_menu_game = new Vec2x2(); + vec2x2_menu_game.x1_pos = 730; + vec2x2_menu_game.y1_pos = 50; + vec2x2_menu_game.x2_size = 170; + vec2x2_menu_game.y2_size = 50; + + + for (int index = 0; index < menu_game.length; index = index + 1 ) { + JButton button = new JButton(); + button.setEnabled(true); + button.setText(menu_game[index]); + + + button.setFont(new Font("Arial", Font.PLAIN, 12)); + button.addActionListener(this); + + button.setBounds( + vec2x2_menu_game.x1_pos, + vec2x2_menu_game.y1_pos, + vec2x2_menu_game.x2_size, + vec2x2_menu_game.y2_size + ); + vec2x2_menu_game.y1_pos = vec2x2_menu_game.y1_pos + 60; + + this.add(button); + menu_game_buttons.add(button); + } + + + user_name = new JTextField("\"Introduce tu nombre\""); + user_name.setBounds( + 405, + 300, + 310, + 50 + ); + + this.add(user_name); + + + + + + // ? ============== Board + Vec2x2 vec2x2_board = new Vec2x2(); + vec2x2_board.x1_pos = 700; + vec2x2_board.y1_pos = 50; + vec2x2_board.x2_size = 170; + vec2x2_board.y2_size = 50; + + + + list_default_model = new DefaultListModel(); + JList list = new JList<>(list_default_model); + list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + list.setBorder(BorderFactory.createTitledBorder("Score")); + + scroll_pane = new JScrollPane(list); + scroll_pane.setBounds(950,40,400,500); + + scroll_pane.setVisible(false); + this.add(scroll_pane); + + menu_game_buttons.get(EnumMenuGame.Reiniciar.ordinal()).setEnabled(false); + + + + Vec2x2 vec2x2_crono = new Vec2x2(); + vec2x2_crono.x1_pos = 510; + vec2x2_crono.y1_pos = 250; + vec2x2_crono.x2_size = 170; + vec2x2_crono.y2_size = 50; + + move_show = new JLabel("Movimientos: 0"); + move_show.setBounds( + vec2x2_crono.x1_pos -100, + vec2x2_crono.y1_pos, + vec2x2_crono.x2_size, + vec2x2_crono.y2_size + ); + this.add(move_show); + + crono_show = new JLabel("Timer: 0"); + crono_show.setBounds( + vec2x2_crono.x1_pos +100, + vec2x2_crono.y1_pos, + vec2x2_crono.x2_size, + vec2x2_crono.y2_size + ); + this.add(crono_show); + this.repaint(); + } + + public void file_read_scanner(String path_file) { + File file = new File(path_file); + + try { + Scanner scanner = new Scanner(file); + while (scanner.hasNextLine()) { + // System.out.println(this.user_data_Vec); + UserData user_data = new UserData(); + user_data.name = scanner.nextLine(); + user_data.crono = Integer.parseInt(scanner.nextLine()); + user_data.movimientos = Integer.parseInt(scanner.nextLine()); + + this.user_data_Vec.add(user_data); + } + } + catch (Exception e) { + System.out.printf("Err read scanner: "); + System.out.println(e.toString()); + } + } + + + public void bubble_sort_list(Vector user_data) { + // %-5s | %-15s | %-17s | %11s + this.list_default_model.addElement(String.format("[%s, %s, %s]", "Nombre", "Segundos", "Movimiento")); + + for(int x = 0; x < user_data.size() - 1; x = x + 1) { + for (int y = 0; y < user_data.size() - x - 1; y = y + 1) { + if (user_data.get(y).crono > user_data.get(y + 1).crono) { + UserData tmp = user_data.get(y); + + user_data.set(y, user_data.get(y + 1)); + user_data.set(y + 1, tmp); + } + } + } + + int limit = 6; + while(user_data.size() >= limit) { + user_data.remove(user_data.size() - 1); + } + + + for(UserData data : user_data) { + this.list_default_model.addElement(String.format("[%s, %s, %s]", data.name, String.valueOf(data.crono), String.valueOf(data.movimientos))); + } + + } + + + public void desorden() { + for (int z = 0; z < puzzle_buttons_vec.size() - 1; z = z + 1) { + int random_number = rnd.nextInt(14) + 1; + + GameButton tmp = puzzle_buttons_vec.get(z); + int tmp_x = tmp.getLocation().x; + int tmp_y = tmp.getLocation().y; + int tmp_x_grid = tmp.x; + int tmp_y_grid = tmp.y; + + GameButton tmp_random = puzzle_buttons_vec.get(random_number); + int tmp_random_x = tmp_random.getLocation().x; + int tmp_random_y = tmp_random.getLocation().y; + int tmp_random_x_grid = tmp_random.x; + int tmp_random_y_grid = tmp_random.y; + + + tmp.setLocation(tmp_random_x, tmp_random_y); + tmp.x = tmp_random_x_grid; + tmp.y = tmp_random_y_grid; + + tmp_random.setLocation(tmp_x, tmp_y); + tmp_random.x = tmp_x_grid; + tmp_random.y = tmp_y_grid; + + puzzle_buttons_vec.set(z, tmp_random); + puzzle_buttons_vec.set(random_number, tmp); + // JButton button_get_z = puzzle_buttons_vec.get(z); + //int button_get_z_x = button_get_z.getLocation().x; + //int button_get_z_y = button_get_z.getLocation().y; + + //JButton button_random = + //int button_random_x = button_random.getLocation().x; + //int button_random_y = button_random.getLocation().y; + + //button_get_z.setLocation(,); + //button_random.setLocation(,); + + //puzzle_buttons_vec.set(random_number, button_random); + + // System.out.printf("%d%n", random_number); + // System.out.println(puzzle_buttons_vec); + } + } + + public void purge_list() { + list_default_model.clear(); + user_data_Vec = new Vector<>(); + } + + + public void ganastes() { + int puzz_index = 0; + for (JButton puzz_but : puzzle_buttons_vec) { + puzz_index = puzz_index + 1; + + if (Integer.parseInt(puzz_but.getText()) == puzz_index) { + if (puzz_index == puzzle_buttons_vec.size()) { + ganastes = true; + break; + } + continue; + } + + break; + } + + if (ganastes) { + try { + + this.my_user_data.crono = crono; + FileWriter file_writer = new FileWriter("storage/data.ini", true); // true=append, false=overwrite + // file_writer.write(String.format("%n")); + file_writer.write(String.format("%s%n", this.my_user_data.name)); + file_writer.write(String.format("%d%n", this.my_user_data.crono)); + file_writer.write(String.format("%d%n", this.my_user_data.movimientos)); + file_writer.close(); + ganastes = false; + System.out.printf("%nGANASTES%n"); + + crono_show.setText(String.format("Timer: %d", crono)); + move_show.setText(String.format("Movimientos: %d", this.my_user_data.movimientos)); + this.my_user_data.movimientos = 0; + + restart(); + + user_name.setText("\"Ganastes\""); + + + } catch(Exception e) { + System.out.println("error grabar " + e.toString()); + } + + } + } + + public void bubble_puzzle() { + + for (JButton puzzle_buttons : puzzle_buttons_vec) { + puzzle_buttons.setEnabled(false); + puzzle_buttons.setVisible(true); + } + + for(int x = 0; x < puzzle_buttons_vec.size() - 1; x = x + 1) { + for (int y = 0; y < puzzle_buttons_vec.size() - x - 1; y = y + 1) { + int puzz_num_1 = Integer.parseInt(puzzle_buttons_vec.get(y).getText()); + int puzz_num_2 = Integer.parseInt(puzzle_buttons_vec.get(y + 1).getText()); + if ( puzz_num_1 > puzz_num_2 ) { + // System.out.println(puzzle_buttons_vec.get(y).getText()); + + GameButton tmp = puzzle_buttons_vec.get(y); + int tmp_x = tmp.getLocation().x; + int tmp_y = tmp.getLocation().y; + int tmp_x_grid = tmp.x; + int tmp_y_grid = tmp.y; + + GameButton tmp_random = puzzle_buttons_vec.get(y + 1); + int tmp_random_x = tmp_random.getLocation().x; + int tmp_random_y = tmp_random.getLocation().y; + int tmp_random_x_grid = tmp_random.x; + int tmp_random_y_grid = tmp_random.y; + // tmp_random.setEnabled(false); + + + tmp.x = tmp_random_x_grid; + tmp.y = tmp_random_y_grid; + tmp_random.x = tmp_x_grid; + tmp_random.y = tmp_y_grid; + + tmp.setLocation(tmp_random_x, tmp_random_y); + tmp_random.setLocation(tmp_x, tmp_y); + + puzzle_buttons_vec.set(y, tmp_random); + puzzle_buttons_vec.set(y + 1, tmp); + + } + } + } + + puzzle_buttons_vec.get(puzzle_buttons_vec.size() - 1).setEnabled(false); + puzzle_buttons_vec.get(puzzle_buttons_vec.size() - 1).setVisible(false); + } + + public void actionPerformed(ActionEvent e) { + if (boton_en_movimiento) { + return; + } + + if (ganastes) { + ganastes = false; + return; + } + + if (e.getSource() == menu_game_buttons.get(EnumMenuGame.Puntuacion.ordinal())) { + purge_list(); + file_read_scanner("storage/data.ini"); + this.bubble_sort_list(this.user_data_Vec); + + if (puntuacion == false) { + scroll_pane.setVisible(true); + puntuacion = true; + } else { + scroll_pane.setVisible(false); + puntuacion = false; + } + return; + } + + if (e.getSource() == menu_game_buttons.get(EnumMenuGame.IniciarDebug.ordinal())) { + if (user_name.getText().equals("\"Introduce tu nombre\"") + || + user_name.getText().equals("\"Ganastes\"") + || + user_name.getText().equals("\"(Elimina todo el texto he introduce tu nombre)\"") + ) { + user_name.setText("\"(Elimina todo el texto he introduce tu nombre)\""); + return; + } + + menu_game_buttons.get(EnumMenuGame.IniciarDebug.ordinal()).setEnabled(false); + menu_game_buttons.get(EnumMenuGame.Iniciar.ordinal()).setEnabled(false); + menu_game_buttons.get(EnumMenuGame.Reiniciar.ordinal()).setEnabled(true); + + user_name.setEnabled(false); + crono = 0; + crono_show.setText(String.format("Timer: %d", crono)); + this.my_user_data.movimientos = 0; + move_show.setText(String.format("Movimientos: %d", this.my_user_data.movimientos)); + timer_crono.start(); + + this.my_user_data.name = user_name.getText(); + + for (JButton puzzle_button : puzzle_buttons_vec) { + puzzle_button.setEnabled(true); + } + puzzle_buttons_vec.get(puzzle_buttons_vec.size() - 1).setEnabled(false); + + + + GameButton tmp_nono_btn = puzzle_buttons_vec.get(puzzle_buttons_vec.size() - 1); + int tmp_nono_btn_x = tmp_nono_btn.getLocation().x; + int tmp_nono_btn_y = tmp_nono_btn.getLocation().y; + int tmp_nono_btn_x_grid = tmp_nono_btn.x; + int tmp_nono_btn_y_grid = tmp_nono_btn.y; + + + GameButton tmp_btn = puzzle_buttons_vec.get(puzzle_buttons_vec.size() - 2); + int tmp_btn_x = tmp_btn.getLocation().x; + int tmp_btn_y = tmp_btn.getLocation().y; + int tmp_btn_x_grid = tmp_btn.x; + int tmp_btn_y_grid = tmp_btn.y; + + + tmp_nono_btn.setLocation(tmp_btn_x, tmp_btn_y); + tmp_nono_btn.x = tmp_btn_x_grid; + tmp_nono_btn.y = tmp_btn_y_grid; + + tmp_btn.setLocation(tmp_nono_btn_x, tmp_nono_btn_y); + tmp_btn.x = tmp_nono_btn_x_grid; + tmp_btn.y = tmp_nono_btn_y_grid; + + puzzle_buttons_vec.set(puzzle_buttons_vec.size() - 2, tmp_nono_btn); + puzzle_buttons_vec.set(puzzle_buttons_vec.size() - 1, tmp_btn); + return; + } + + if (e.getSource() == menu_game_buttons.get(EnumMenuGame.Reiniciar.ordinal())) { + restart(); + + return; + } + + + + if (e.getSource() == menu_game_buttons.get(EnumMenuGame.Iniciar.ordinal())) { + if (user_name.getText().equals("\"Introduce tu nombre\"") + || + user_name.getText().equals("\"Ganastes\"") + || + user_name.getText().equals("\"(Elimina todo el texto he introduce tu nombre)\"") + ) { + user_name.setText("\"(Elimina todo el texto he introduce tu nombre)\""); + return; + } + + menu_game_buttons.get(EnumMenuGame.Reiniciar.ordinal()).setEnabled(true); + menu_game_buttons.get(EnumMenuGame.Iniciar.ordinal()).setEnabled(false); + menu_game_buttons.get(EnumMenuGame.IniciarDebug.ordinal()).setEnabled(false); + + + this.my_user_data.name = user_name.getText(); + crono = 0; + crono_show.setText(String.format("Timer: %d", crono)); + timer_crono.start(); + + this.desorden(); + + + for (JButton puzzle_button : puzzle_buttons_vec) { + puzzle_button.setEnabled(true); + puzzle_button.setVisible(true); + } + + puzzle_buttons_vec.get(puzzle_buttons_vec.size() - 1).setEnabled(false); + puzzle_buttons_vec.get(puzzle_buttons_vec.size() - 1).setVisible(false); + + user_name.setEnabled(false); + + return; + } + + if (e.getSource() instanceof GameButton) { + // ! Cast + GameButton cmp_button = (GameButton) e.getSource(); + + GameButton puzz_sisi_btn = new GameButton(); + GameButton puzz_nono_btn = new GameButton(); + int puzz_vec_pos = 0; + + boolean in_loop = true; + for (GameButton puzzle : puzzle_buttons_vec) { + if (cmp_button == puzzle) { + puzz_sisi_btn = puzzle; + puzz_sisi_btn.vec_pos = puzz_vec_pos; + puzz_vec_pos = 0; + in_loop = false; + break; + } + puzz_vec_pos = puzz_vec_pos + 1; + } + + if (in_loop) { + return; + } + + for (GameButton puzzle_nono_btn : puzzle_buttons_vec) { + if (puzzle_nono_btn.isEnabled() == false) { + puzz_nono_btn = puzzle_nono_btn; + puzz_nono_btn.vec_pos = puzz_vec_pos; + puzz_vec_pos = 0; + break; + } + puzz_vec_pos = puzz_vec_pos + 1; + } + + System.out.printf( + "Puzzz: Name:%s X:%d Y:%d %n", + puzz_sisi_btn.getText(), + puzz_sisi_btn.x, + puzz_sisi_btn.y); + + System.out.printf( + "Puzzz Nono: Name:%s X:%d Y:%d %n", + puzz_nono_btn.getText(), + puzz_nono_btn.x, + puzz_nono_btn.y); + + + if ( + puzz_sisi_btn.x == puzz_nono_btn.x + && + puzz_sisi_btn.y + 1 == puzz_nono_btn.y + + || + + puzz_sisi_btn.x + 1 == puzz_nono_btn.x + && + puzz_sisi_btn.y == puzz_nono_btn.y + + || + + puzz_sisi_btn.x == puzz_nono_btn.x + && + puzz_sisi_btn.y - 1 == puzz_nono_btn.y + + || + + puzz_sisi_btn.x - 1 == puzz_nono_btn.x + && + puzz_sisi_btn.y == puzz_nono_btn.y + ) { + System.out.printf("Valid click btn%n"); + mover(puzz_sisi_btn, puzz_nono_btn); + return; + } + } + + } + + + + public void mover(GameButton sisi, GameButton nono) { + System.out.printf("Mover%n"); + this.my_user_data.movimientos = this.my_user_data.movimientos + 1; + move_show.setText(String.format("Movimientos: %d", this.my_user_data.movimientos)); + + anim_btn_vec_pos = nono.vec_pos; + + System.out.printf("Debug pos sisi: %d nono %d%n", sisi.vec_pos, nono.vec_pos); + GameButton tmp_btn_sisi = puzzle_buttons_vec.get(sisi.vec_pos); + int tmp_btn_sisi_x = tmp_btn_sisi.getLocation().x; + int tmp_btn_sisi_y = tmp_btn_sisi.getLocation().y; + int tmp_btn_sisi_x_grid = tmp_btn_sisi.x; + int tmp_btn_sisi_y_grid = tmp_btn_sisi.y; + + + GameButton tmp_btn_nono = puzzle_buttons_vec.get(nono.vec_pos); + int tmp_btn_nono_x = tmp_btn_nono.getLocation().x; + int tmp_btn_nono_y = tmp_btn_nono.getLocation().y; + int tmp_btn_nono_x_grid = tmp_btn_nono.x; + int tmp_btn_nono_y_grid = tmp_btn_nono.y; + + + // tmp_sisi.setLocation(tmp_nono_x, tmp_nono_y); + tmp_btn_sisi.x = tmp_btn_nono_x_grid; + tmp_btn_sisi.y = tmp_btn_nono_y_grid; + tmp_btn_sisi.x_anim = tmp_btn_nono_x; + tmp_btn_sisi.y_anim = tmp_btn_nono_y; + + tmp_btn_nono.setLocation(tmp_btn_sisi_x, tmp_btn_sisi_y); + tmp_btn_nono.x = tmp_btn_sisi_x_grid; + tmp_btn_nono.y = tmp_btn_sisi_y_grid; + + + puzzle_buttons_vec.set(sisi.vec_pos, tmp_btn_nono); + puzzle_buttons_vec.set(nono.vec_pos, tmp_btn_sisi); + + btn_movimiento_tmp = puzzle_buttons_vec.get(anim_btn_vec_pos); + timer_move_anim.start(); + } + + public void restart() { + menu_game_buttons.get(EnumMenuGame.Reiniciar.ordinal()).setEnabled(false); + menu_game_buttons.get(EnumMenuGame.IniciarDebug.ordinal()).setEnabled(true); + menu_game_buttons.get(EnumMenuGame.Iniciar.ordinal()).setEnabled(true); + + user_name.setText("\"Introduce tu nombre\""); + + timer_crono.stop(); + user_name.setEnabled(true); + crono = 0; + this.my_user_data.movimientos = 0; + + crono_show.setText(String.format("Timer: %d", crono)); + move_show.setText(String.format("Movimientos: %d", this.my_user_data.movimientos)); + this.bubble_puzzle(); + + this.purge_list(); + file_read_scanner("storage/data.ini"); + this.bubble_sort_list(this.user_data_Vec); + } +} \ No newline at end of file diff --git a/project/rompecabeza/src/com/mod/util/GameButton.java b/project/rompecabeza/src/com/mod/util/GameButton.java new file mode 100755 index 0000000..e084314 --- /dev/null +++ b/project/rompecabeza/src/com/mod/util/GameButton.java @@ -0,0 +1,11 @@ +package mod.util; + +import javax.swing.*; +import java.awt.event.*; + +public class GameButton extends JButton { + public int x, y; + public int vec_pos; + public int x_anim; + public int y_anim; +} \ No newline at end of file diff --git a/project/rompecabeza/src/com/mod/util/UserData.java b/project/rompecabeza/src/com/mod/util/UserData.java new file mode 100644 index 0000000..b265eff --- /dev/null +++ b/project/rompecabeza/src/com/mod/util/UserData.java @@ -0,0 +1,7 @@ +package mod.util; + +public class UserData { + public String name; + public int crono; + public int movimientos; +} \ No newline at end of file diff --git a/project/rompecabeza/src/com/mod/util/Vec2D.java b/project/rompecabeza/src/com/mod/util/Vec2D.java new file mode 100644 index 0000000..ff197db --- /dev/null +++ b/project/rompecabeza/src/com/mod/util/Vec2D.java @@ -0,0 +1,11 @@ +package mod.util; + +public class Vec2D { + public int x; + public int y; + + public Vec2D() { + this.x = 0; + this.y = 0; + } +} \ No newline at end of file diff --git a/project/rompecabeza/src/com/mod/util/Vec2x2.java b/project/rompecabeza/src/com/mod/util/Vec2x2.java new file mode 100644 index 0000000..a676147 --- /dev/null +++ b/project/rompecabeza/src/com/mod/util/Vec2x2.java @@ -0,0 +1,25 @@ +package mod.util; + +public class Vec2x2 { + // Position + public int x1_pos; + public int y1_pos; + + // Size + public int x2_size; + public int y2_size; + + public Vec2x2() { + this.x1_pos = 0; + this.y1_pos = 0; + this.x2_size = 0; + this.y2_size = 0; + } + + public Vec2x2(int x1, int y1, int x2, int y2) { + this.x1_pos = x1; + this.y1_pos = y1; + this.x2_size = x2; + this.y2_size = y2; + } +} \ No newline at end of file