├── .github ├── FUNDING.yml └── ISSUE_TEMPLATE │ └── petici-n-de-programa---lenguaje.md ├── .gitignore ├── C++ ├── README.md ├── control-de-listas.cpp ├── control-de-notas.cpp ├── conversion-de-grados-F-a-C.cpp ├── ejemplo-de clases.cpp └── juego-test-de-personalidad.cpp ├── CODE_OF_CONDUCT.md ├── LICENSE ├── README.md ├── java ├── Alquiler_libros │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── mycompany │ │ └── alquiler_libros │ │ ├── Libro.java │ │ ├── Revista.java │ │ └── main.java ├── README.md ├── cuentas │ ├── cuenta.java │ ├── main.java │ └── titular.java ├── diccionarios-anidados │ ├── pom.xml │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ └── mycompany │ │ │ └── matrizenergeticas │ │ │ └── main.java │ └── target │ │ ├── classes │ │ └── com │ │ │ └── mycompany │ │ │ └── matrizenergeticas │ │ │ └── main.class │ │ └── maven-status │ │ └── maven-compiler-plugin │ │ └── compile │ │ └── default-compile │ │ ├── createdFiles.lst │ │ └── inputFiles.lst ├── inmutabilidad │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── mycompany │ │ └── inmutabilidad │ │ └── main.java ├── matrices.java ├── midespensa │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── mycompany │ │ └── midespensa │ │ ├── App.java │ │ ├── DBUtil.java │ │ ├── Launch.java │ │ ├── classes │ │ ├── article.java │ │ ├── client.java │ │ ├── factura.java │ │ ├── persona.java │ │ └── proveedor.java │ │ ├── controllers │ │ ├── clientController.java │ │ └── mainController.java │ │ ├── models │ │ └── Clients.java │ │ ├── repositories │ │ └── ClientRepository.java │ │ └── screens │ │ ├── addclient.form │ │ ├── addclient.java │ │ ├── addprod.form │ │ ├── addprod.java │ │ ├── clientes.form │ │ ├── clientes.java │ │ ├── compra.form │ │ ├── compra.java │ │ ├── factura.form │ │ ├── factura.java │ │ ├── home.form │ │ ├── home.java │ │ ├── main.form │ │ ├── main.java │ │ ├── productos.form │ │ └── productos.java ├── progressbar-hilos │ ├── main.form │ └── main.java └── restaurante │ ├── .classpath │ ├── .project │ ├── .settings │ ├── org.eclipse.core.resources.prefs │ ├── org.eclipse.jdt.apt.core.prefs │ ├── org.eclipse.jdt.core.prefs │ └── org.eclipse.m2e.core.prefs │ ├── pom.xml │ └── src │ └── main │ └── java │ └── com │ └── mycompany │ └── restaurante │ ├── main.java │ └── users │ └── client.java ├── javascript ├── README.md └── strings.js └── python ├── README.md ├── calcular-derivadas-simples.py ├── calcular-pago-empleados.py ├── calcular-ventas-de-sucursales.py ├── conversion-base-de-numeros.py ├── diagnosticar-leucemia-aguda.py ├── imprimir-factura.py ├── mostrar-hora-y-fecha.py ├── numeros-primos.py ├── registro-de-estudiantes.py └── sistema-de-biblioteca.py /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | custom: ['https://paypal.me/tomvargas'] # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/petici-n-de-programa---lenguaje.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Petición de programa / lenguaje 3 | about: Aporta una idea para este proyecto ✨ 4 | title: Solicitud de características 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Tu mensaje realmente coincide con el tema a tratar?** 11 | Se claro(a) y especifico(a), directo al grano, por ejemplo, "Propongo agregar ejercicios con el lenguaje PHP" 12 | 13 | **Describe tu propuesta para evitar ambigüedades** 14 | Específica que ejercicios te interesaría entre otras cosas que desees detallar. 15 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /java/restaurante/target/ 2 | /java/Alquiler_libros/target/ 3 | /java/midespensa/target/ 4 | /java/inmutabilidad/target/ 5 | /java/matrizEnergeticas/target/ 6 | 7 | /.vscode -------------------------------------------------------------------------------- /C++/README.md: -------------------------------------------------------------------------------- 1 | # EJERCICIOS DE C++ 2 | En esta carpeta puedes encontrar varios ejercicios de C++ si necesitas aprender algo en específico de este lenguaje te invito a dejarme un comentario en [este foro de discusión](https://github.com/Tomvargas/Programas/discussions/3). 3 | Te dejo una lista con la descripción de cada uno de los ejercicios en este nivel: 4 | * ### Control de listas 5 | Agrega elemento al final, al inicio, busca un elemento, elimina un elemento. 6 | * ### Control de notas 7 | Registra las notas de un estudiante, muestra el promedio y estado, Muestra el estudiante con mejor y peor promedio. 8 | * ### Conversión de F° a C° 9 | Contierte los grados ingresados en F° a C°. 10 | * ### Juego test de personalidad 11 | Serie de preguntas para calcular un puntaje y mostrar un mensaje de su personalidad en base a las preguntas contestadas. 12 | * ### Ejemplo de clases 13 | Crea una clase con los datos de nombre, dirección y profesión, luego lo muestra por pantalla. 14 | -------------------------------------------------------------------------------- /C++/control-de-listas.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | int printlist(int n, int lista[100]){ 8 | for(int i=0; i99){ 27 | cout<<"La lista esta llena, no puede ingresar mas numeros..."<>n; 42 | if(n>100){ 43 | cout<<"No puede ingresar más de 100 numeros..."<>lista[i]; 48 | } 49 | printlist(n,lista); 50 | 51 | int op; 52 | valid=0; 53 | do { 54 | system("cls"); 55 | printmenu(); 56 | cout<<"Ingrese el numero de una opcion: "; 57 | cin>>op; 58 | switch(op){ 59 | case 1: 60 | if (validsize(n)==1){ 61 | n+=1; 62 | cout<<"Ingrese el numero: "; 63 | cin>>lista[n-1]; 64 | } 65 | 66 | break; 67 | 68 | case 2: 69 | if(validsize(n)==1){ 70 | int newnum; 71 | n+=1; 72 | cout<<"Ingrese el numero: "; cin>>newnum; 73 | for (int i=n-1; i>=0; i--){ 74 | lista[i]=lista[i-1]; 75 | } 76 | lista[0]=newnum; 77 | } 78 | 79 | break; 80 | 81 | case 3: 82 | int pos; 83 | do{ 84 | cout<<"Ingrese la posicion del numero que desea eliminar: "; 85 | cin>>pos; 86 | if(pos>(n-1)||pos<0) 87 | cout<<">>Ingrese una posicion valida!!!"<(n-1)||pos<0); 89 | 90 | for(int i=pos;i>pos1; 100 | if (pos1>n-1 || pos1<0){ 101 | cout<<"La posicion ingresada no existe..."; 102 | system("pause"); 103 | }else{ 104 | cout<<"Posición | Numero"< Ingresar las notas del estudiante. 6 | -> Obtener el promedio y mostrar mensaje de estado del estudiante. 7 | -> Mostrar el mejor estudiante y el peor de la clase. 8 | 9 | @author tomvargas 10 | *-----------------------------------------------------------------------------*/ 11 | #include 12 | #include 13 | using namespace std; 14 | 15 | /*-----------------------------------------------------------------------------* 16 | === variables globales === 17 | *-----------------------------------------------------------------------------*/ 18 | int num_est; 19 | string nombre[45]; 20 | int p1[45][5], ex1[45][5], p2[45][5], ex2[45][5]; //notas de la matriz 21 | float promedio[45][5];//promedio de la matriz 22 | 23 | /*-----------------------------------------------------------------------------* 24 | 25 | ### FUNCIONES ### 26 | 27 | *-----------------------------------------------------------------------------*/ 28 | 29 | /*-----------------------------------------------------------------------------* 30 | === FUNCION MENU PRINCIPAL === 31 | *-----------------------------------------------------------------------------*/ 32 | void menu() 33 | { 34 | system("cls");//LIMPIAR PANTALLA 35 | 36 | cout<<"\t***** CONTROL DE NOTAS *****"< INGRESE UNA OPCION: "; 43 | } 44 | 45 | /*-----------------------------------------------------------------------------* 46 | === FUNCION INGRESAR ESTUDIANTES === 47 | *-----------------------------------------------------------------------------*/ 48 | void ingresar() 49 | { 50 | int numest, i; 51 | 52 | estudiantes: //etiqueta identificadora para "goto" 53 | system("cls"); 54 | 55 | cout< Cuantos estudiantes desea ingresar? "; 56 | cin>>numest; 57 | 58 | if(numest>45) 59 | { 60 | cout<<"no puede haber mas de 45 estudiantes. vuelva a intentar."< nombre del estudiante: "; 73 | cin>>nombre[i]; 74 | cout<<"-> nota academica del primer parcial: "; 75 | cin>>p1[i][1]; 76 | cout<<"-> nota del examen del primer parcial: "; 77 | cin>>ex1[i][2]; 78 | cout<<"-> nota academica del segundo parcial: "; 79 | cin>>p2[i][3]; 80 | cout<<"-> nota del examen del segundo parcial: "; 81 | cin>>ex2[i][4]; 82 | 83 | promedio[i][5]=(((p1[i][1]+ex1[i][2])/2) + ((p2[i][3]+ex2[i][4])/2))/2; 84 | system("pause"); 85 | } 86 | } 87 | } 88 | 89 | /*-----------------------------------------------------------------------------* 90 | === FUNCION PRROMEDIO DE ESTUDIANTES === 91 | *-----------------------------------------------------------------------------*/ 92 | void promest() 93 | { 94 | int op2, i; 95 | prom: 96 | 97 | system("cls"); 98 | cout<<"*** promedio de los estudiantes ***"< "< Ingresar el numero de estudiante o ingrese 0 para ir al menu principal."<>op2; 106 | 107 | if(op2>num_est) 108 | { 109 | cout<<" -- Ingrese un numero correcto --"< Nombre: "< Nota academica parcial 1: "< Nota del examen parcial 1: "< Nota academica del parcial 2: "< Nota del examen parcial 2: "< Nota del promedio total: "<=7) 128 | { 129 | cout<<"\t-> El estudiante aprobo."<=5 && promedio[op2][5]<7) 133 | { 134 | cout<<"\t-> El estudiante va a mejoramiento."< el estudiante reprobo."<cont1) 182 | { 183 | cont1=promedio[i][5]; 184 | aux1=i; 185 | } 186 | 187 | if(promedio[i][5] NO HAY MEJOR NI PEOR ESTUDIANTE, TODOS TIENEN UN PROMEDIO DE "< El mejor estudiante es: "< El peor estudiante es: "<>op; 221 | 222 | if(op>5) 223 | { 224 | cout<<"\t-> Opcion incorrecta, vuelva a intentar."< 2 | #include 3 | 4 | //@author tomvargas 5 | 6 | using namespace std; 7 | 8 | main(){ 9 | int F,C; 10 | 11 | cout<<"\t### CONVERSION DE GRADOS F A C ###"< Ingrese el dato en grados F: "; 15 | cin>>F; 16 | 17 | //formula 18 | C=(F-32)/1.800; 19 | 20 | cout<<">> Resultado: "< 2 | 3 | using namespace std; 4 | 5 | class Person{ 6 | public: 7 | string name; 8 | string dir; 9 | string prof; 10 | }; 11 | 12 | main(){ 13 | system("color 0b"); 14 | Person obj; //objeto 15 | int op; 16 | cp: 17 | system("cls"); 18 | cout<>obj.name; 19 | cout<<"\tIngresa la direccion de "<>obj.dir; 20 | cout<<"\tIngresar la profecion de "<>obj.prof; 21 | cout<>op; 30 | if (op==1) 31 | goto cp; 32 | 33 | system("pause"); 34 | } -------------------------------------------------------------------------------- /C++/juego-test-de-personalidad.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | //@author tomvargas 5 | 6 | using namespace std; 7 | 8 | void talent(); 9 | 10 | main() 11 | { 12 | int op; 13 | menu: 14 | cout<>>"< Ingrese una opcion: "; 20 | cin >> op; 21 | 22 | switch (op) 23 | { 24 | case 1: 25 | system("cls"); 26 | talent(); 27 | cout<>>"< Ingrese una opcion: "; 50 | cin >> opc; 51 | switch (opc) 52 | { 53 | case 1: 54 | val = val + 20; 55 | break; 56 | case 2: 57 | val = val + 40; 58 | break; 59 | case 3: 60 | val = val + 30; 61 | break; 62 | case 4: 63 | val = val + 10; 64 | break; 65 | case 5: 66 | val = val + 60; 67 | break; 68 | case 6: 69 | val = val + 50; 70 | break; 71 | case 7: 72 | val = val + 70; 73 | break; 74 | } 75 | }while(opc>7); 76 | system("pause"); system("cls"); 77 | //----------------------------------------------------------------- 78 | 79 | cout<>>"< Ingrese una opcion: "; 90 | cin >> opc; 91 | switch (opc) 92 | { 93 | case 1: 94 | val = val + 40; 95 | break; 96 | case 2: 97 | val = val + 30; 98 | break; 99 | case 3: 100 | val = val + 10; 101 | break; 102 | case 4: 103 | val = val + 20; 104 | break; 105 | case 5: 106 | val = val + 50; 107 | break; 108 | case 6: 109 | val = val + 70; 110 | break; 111 | case 7: 112 | val = val + 60; 113 | break; 114 | } 115 | }while(opc>7); 116 | system("pause"); system("cls"); 117 | //-------------------------------------------------------------------- 118 | cout<>>"< Ingrese una opcion: "; 129 | cin >> opc; 130 | switch (opc) 131 | { 132 | case 1: 133 | val = val + 10; 134 | break; 135 | case 2: 136 | val = val + 70; 137 | break; 138 | case 3: 139 | val = val + 40; 140 | break; 141 | case 4: 142 | val = val + 30; 143 | break; 144 | case 5: 145 | val = val + 20; 146 | break; 147 | case 6: 148 | val = val + 60; 149 | break; 150 | case 7: 151 | val = val + 50; 152 | break; 153 | } 154 | }while(opc>7); 155 | system("pause"); system("cls"); 156 | //------------------------------------------------------------------- 157 | cout<>>"< Ingrese una opcion: "; 168 | cin >> opc; 169 | switch (opc) 170 | { 171 | case 1: 172 | val = val + 20; 173 | break; 174 | case 2: 175 | val = val + 60; 176 | break; 177 | case 3: 178 | val = val + 40; 179 | break; 180 | case 4: 181 | val = val + 70; 182 | break; 183 | case 5: 184 | val = val + 50; 185 | break; 186 | case 6: 187 | val = val + 30; 188 | break; 189 | case 7: 190 | val = val + 10; 191 | break; 192 | } 193 | }while(opc>7); 194 | system("pause"); system("cls"); 195 | //------------------------------------------------------------------ 196 | cout<>>"< Ingrese una opcion: "; 207 | cin >> opc; 208 | switch (opc) 209 | { 210 | case 1: 211 | val = val + 70; 212 | break; 213 | case 2: 214 | val = val + 50; 215 | break; 216 | case 3: 217 | val = val + 40; 218 | break; 219 | case 4: 220 | val = val + 30; 221 | break; 222 | case 5: 223 | val = val + 10; 224 | break; 225 | case 6: 226 | val = val + 20; 227 | break; 228 | case 7: 229 | val = val + 60; 230 | break; 231 | } 232 | }while(opc>7); 233 | system("pause"); system("cls"); 234 | //---------------------------------------------------------------- 235 | 236 | cout<>>"<>opc; 247 | switch(opc) 248 | { 249 | case 1: val=val+70; break; 250 | case 2: val=val+20; break; 251 | case 3: val=val+50; break; 252 | case 4: val=val+30; break; 253 | case 5: val=val+60; break; 254 | case 6: val=val+40; break; 255 | case 7: val=val+10; break; 256 | }}while(opc>7); 257 | system("pause"); system("cls"); 258 | //----------------------------------------------------------------- 259 | 260 | cout<>>"< Ingrese una opcion: "; 271 | cin >> opc; 272 | switch (opc) 273 | { 274 | case 1: 275 | val = val + 10; 276 | break; 277 | case 2: 278 | val = val + 40; 279 | break; 280 | case 3: 281 | val = val + 20; 282 | break; 283 | case 4: 284 | val = val + 30; 285 | break; 286 | case 5: 287 | val = val + 60; 288 | break; 289 | case 6: 290 | val = val + 70; 291 | break; 292 | case 7: 293 | val = val + 50; 294 | break; 295 | } 296 | }while(opc>7); 297 | system("pause"); system("cls"); 298 | //------------------------------------------------------------------ 299 | 300 | cout<>>"< Ingrese una opcion: "; 311 | cin >> opc; 312 | switch (opc) 313 | { 314 | case 1: 315 | val = val + 70; 316 | break; 317 | case 2: 318 | val = val + 10; 319 | break; 320 | case 3: 321 | val = val + 20; 322 | break; 323 | case 4: 324 | val = val + 30; 325 | break; 326 | case 5: 327 | val = val + 40; 328 | break; 329 | case 6: 330 | val = val + 50; 331 | break; 332 | case 7: 333 | val = val + 60; 334 | break; 335 | } 336 | }while(opc>7); 337 | system("pause"); system("cls"); 338 | //---------------------------------------------------------------- 339 | 340 | cout<>>"<>opc; 351 | cout << "> Ingrese una opcion: "; 352 | switch (opc) 353 | { 354 | case 1: 355 | val = val + 10; 356 | break; 357 | case 2: 358 | val = val + 30; 359 | break; 360 | case 3: 361 | val = val + 20; 362 | break; 363 | case 4: 364 | val = val + 50; 365 | break; 366 | case 5: 367 | val = val + 40; 368 | break; 369 | case 6: 370 | val = val + 60; 371 | break; 372 | case 7: 373 | val = val + 70; 374 | break; 375 | } 376 | }while(opc>7); 377 | system("pause"); system("cls"); 378 | 379 | //----------------------------------------------------------------- 380 | 381 | cout<>>"<>opc; 392 | cout << "> Ingrese una opcion: " 393 | 394 | switch (opc) 395 | { 396 | case 1: 397 | val = val + 70; 398 | break; 399 | case 2: 400 | val = val + 60; 401 | break; 402 | case 3: 403 | val = val + 50; 404 | break; 405 | case 4: 406 | val = val + 40; 407 | break; 408 | case 5: 409 | val = val + 30; 410 | break; 411 | case 6: 412 | val = val + 20; 413 | break; 414 | case 7: 415 | val = val + 10; 416 | break; 417 | } 418 | }while(opc>7); 419 | system("pause"); system("cls"); 420 | 421 | //---------------------------------------------------------------------- 422 | //---------------------------------------------------------------------- 423 | 424 | if (val>99 && val<161) 425 | { 426 | cout<>>"<169 && val<231) 433 | { 434 | cout<>>"<239 && val<341) 441 | { 442 | cout<>>"<349 && val<441) 449 | { 450 | cout<>>"<449 && val<541) 457 | { 458 | cout<>>"<99 && val<161) 465 | { 466 | cout<>>"<629 && val<701) 473 | { 474 | cout<>>"< C++ 7 | ### Python 8 | ### Java 9 | ### JavaScript 10 | 11 |
12 | Dame una estrellita y sigueme para estar actualizado. 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /java/Alquiler_libros/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | com.mycompany 5 | Alquiler_libros 6 | 1.0-SNAPSHOT 7 | jar 8 | 9 | UTF-8 10 | 15 11 | 15 12 | 13 | -------------------------------------------------------------------------------- /java/Alquiler_libros/src/main/java/com/mycompany/alquiler_libros/Libro.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package com.mycompany.alquiler_libros; 7 | 8 | interface Prestable{ 9 | public boolean prestado=false; 10 | 11 | public void prestar(); 12 | public void devolver(); 13 | 14 | } 15 | /** 16 | * @author tomvargas 17 | */ 18 | public class Libro implements Prestable { 19 | private String code; 20 | private String title; 21 | private int year; 22 | private boolean pr=prestado; 23 | 24 | public Libro (String code, String title, int year){ 25 | this.code=code; 26 | this.title=title; 27 | this.year=year; 28 | } 29 | 30 | public String getCode(){ return code; } 31 | public String getTitle(){ return title; } 32 | public int getYear(){ return year; } 33 | public boolean getStatus(){ return pr; } 34 | 35 | public void prestar(){ 36 | pr=true; 37 | System.out.println("Usted ha alquilado este libro"); 38 | } 39 | 40 | public void devolver(){ 41 | pr=false; 42 | System.out.println("Usted ha devuelto este libro"); 43 | } 44 | 45 | 46 | public String toString(){ 47 | String estado = "desconocido"; 48 | if (pr) 49 | estado="Prestado"; 50 | else 51 | estado="Disponible"; 52 | return ("Titulo: "+title+"\nCodigo: "+code+"\nAnio: "+year+"\nEstado: "+estado); 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /java/Alquiler_libros/src/main/java/com/mycompany/alquiler_libros/Revista.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package com.mycompany.alquiler_libros; 7 | 8 | /** 9 | * 10 | * @author tomvargas 11 | */ 12 | public class Revista { 13 | 14 | private String code; 15 | private String title; 16 | private int year; 17 | private int number; 18 | 19 | public Revista(String code, String title, int year, int number){ 20 | this.code=code; 21 | this.title=title; 22 | this.year=year; 23 | this.number=number; 24 | } 25 | 26 | public int getYear(){ return year; } 27 | 28 | public String toString(){ 29 | return ("Revista: "+title+"\nCodigo: "+code+"\nAnio: "+year+"\nNumero: "+number ); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /java/Alquiler_libros/src/main/java/com/mycompany/alquiler_libros/main.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package com.mycompany.alquiler_libros; 7 | import java.util.ArrayList; 8 | 9 | /** 10 | * 11 | * @author tomvargas 12 | */ 13 | public class main { 14 | 15 | public static int cuentaPrestados(ArrayList bookList){ 16 | int count=0; 17 | for (int i=0; i retornaPrestados(ArrayList bookList){ 27 | ArrayList newlist = new ArrayList(); 28 | 29 | for (int i=0; i magList, int y){ 39 | int count=0; 40 | for (int i=0; i books = new ArrayList(); 62 | ArrayList mag = new ArrayList(); 63 | 64 | books.add(newbook("001","1000 anios de soledad",1998)); 65 | books.add(newbook("002","Software modeling and design",2011)); 66 | books.add(newbook("003","Metodología y herramientas UML",2005)); 67 | books.add(newbook("004","Viaje al centro de la tierra",1997)); 68 | books.add(newbook("005","Ciencias naturales",2017)); 69 | books.add(newbook("006","El señor de los anillos",1998)); 70 | books.add(newbook("007","Harry Potter",1998)); 71 | books.add(newbook("008","Anatomía humana",1998)); 72 | books.add(newbook("009","Algebra de baldor",1998)); 73 | books.add(newbook("010","Historia de la informática",1998)); 74 | 75 | //-----------------------------------------------prestar 5 publicaciones 76 | for (int i=0; i Ingrese el monto a depositar"); 77 | monto = insert.nextDouble(); 78 | if (monto <1){ 79 | System.out.println("No puede depositar menos de $1,00"); 80 | }else{ 81 | val = 1; 82 | double saldoactual = this.getSaldoini() + monto; 83 | this.setSaldoini(saldoactual); 84 | System.out.println("Su deposito se ha realizado..."); 85 | } 86 | }while(val == 0); 87 | } 88 | 89 | public void retirar(){ 90 | Scanner insert = new Scanner (System.in); 91 | double monto; 92 | int val=0; 93 | do{ 94 | System.out.println("> Ingrese el monto a retirar"); 95 | monto = insert.nextDouble(); 96 | if (monto <1){ 97 | System.out.println("No puede depositar menos de $1,00"); 98 | }else{ 99 | val = 1; 100 | double saldoactual = this.getSaldoini(); 101 | if((saldoactual-monto) < 0){ 102 | System.out.println("Su saldo actual no permite retirar el monto ingresado"); 103 | }else{ 104 | saldoactual = saldoactual - monto; 105 | this.setSaldoini(saldoactual); 106 | System.out.println("Su Retiro se ha realizado..."); 107 | } 108 | } 109 | }while(val == 0); 110 | } 111 | 112 | public void consulta(){ 113 | String var = "Cuenta Bancaria N° "+this.getId()+"\n-----------------"; 114 | var = var+"\nTitular: "+super.getNombre()+"\nFecha de de apertura: "+this.getFechaini(); 115 | var = var+"\nSaldo actual de la cuenta: $"+this.getSaldoini(); 116 | if(!this.getTipo()){ 117 | System.out.println("<< AVISO: SU CUENTA CORRIENTE TIENE UN COSTO DE MANTENIMIENTO DE $"+this.getValor()+" CADA 3 MESES >>"); 118 | }else{ 119 | System.out.println("<< AVISO: SU CUENTA DE AHORROS TIENE UN INTERES QUE SE ACREDITA $"+this.getValor()+" CADA 3 MESES >>"); 120 | } 121 | System.out.println(var); 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /java/cuentas/main.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package com.mycompany.cuentas; 7 | import java.lang.String; 8 | import java.util.Date; 9 | import java.util.Scanner; 10 | 11 | /** 12 | * @author tomvargas 13 | */ 14 | public class main { 15 | 16 | public static void main(String args[]){ 17 | Scanner insert = new Scanner (System.in); 18 | cuenta c1 = new cuenta (); 19 | int id; 20 | double saldo = -1; 21 | String fecha = ""; 22 | Boolean tipovalor = false; 23 | int tipo; 24 | double valor = 0; 25 | String nombre = ""; 26 | String cedula = ""; 27 | 28 | Date fech = new Date(); 29 | int op; 30 | 31 | System.out.println("Registre su cuenta bancaria"); 32 | System.out.println("> Ingrese Su nombre completo: "); 33 | nombre = insert.nextLine(); 34 | System.out.println("> Ingrese su numero de cedula: "); 35 | cedula = insert.nextLine(); 36 | id = 1223; 37 | while(saldo < 0){ 38 | 39 | System.out.println("> Inserte el monto del deposito inicial: $"); 40 | saldo = insert.nextDouble(); 41 | if(saldo < 0 ){ 42 | System.out.println("No puede insertar un monto en negativo"); 43 | } 44 | } 45 | 46 | fecha = fech.toString(); 47 | 48 | tipo = 2; 49 | do{ 50 | System.out.println("> Elija que tipo de cuenta desea (1 = Cnta. de ahorros || 0 = Cnta. corriente): "); 51 | tipo = insert.nextInt(); 52 | if (tipo == 1){ 53 | 54 | tipovalor = true; 55 | valor = 2.5; 56 | } 57 | else{ 58 | if(tipo == 0){ 59 | 60 | tipovalor = false; 61 | valor = 2.5; 62 | } 63 | else{ 64 | System.out.println("Debe insertar 1 o 0"); 65 | } 66 | } 67 | }while(tipo == 2); 68 | 69 | c1.registrar_cuenta(id, saldo, fecha, tipovalor, valor, nombre, cedula); 70 | int ex = 0; 71 | do{ 72 | System.out.println("GESTION DE CUENTA BANCARIA"); 73 | double s = c1.getSaldoini(); 74 | if(s==0){ 75 | System.out.println("<< Aviso: Su cuenta está en $0,00 >>"); 76 | } 77 | System.out.println("1) Depositar dinero.\n2) Retirar dinero\n3) Consultar saldo disponible\n4) Salir"); 78 | op = insert.nextInt(); 79 | switch(op){ 80 | case 1: 81 | c1.depositar(); 82 | break; 83 | case 2: 84 | c1.retirar(); 85 | break; 86 | case 3: 87 | c1.consulta(); 88 | break; 89 | case 4: 90 | ex=1; 91 | break; 92 | default: 93 | System.out.println("Opcion no valida"); 94 | } 95 | }while(ex==0); 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /java/cuentas/titular.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package com.mycompany.cuentas; 7 | import java.lang.String; 8 | 9 | /** 10 | * 11 | * @author tomvargas 12 | */ 13 | public class titular { 14 | private String nombre; 15 | private String cedula; 16 | 17 | public String getNombre() { 18 | return nombre; 19 | } 20 | 21 | public void setNombre(String nombre) { 22 | this.nombre = nombre; 23 | } 24 | 25 | public String getCedula() { 26 | return cedula; 27 | } 28 | 29 | public void setCedula(String cedula) { 30 | this.cedula = cedula; 31 | } 32 | 33 | public void registrar_titular(String nom, String ced){ 34 | setNombre(nom); 35 | setCedula(ced); 36 | System.out.println("Se registro el titular"); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /java/diccionarios-anidados/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | com.mycompany 5 | matrizEnergeticas 6 | 1.0-SNAPSHOT 7 | jar 8 | 9 | UTF-8 10 | 15 11 | 15 12 | 13 | -------------------------------------------------------------------------------- /java/diccionarios-anidados/src/main/java/com/mycompany/matrizenergeticas/main.java: -------------------------------------------------------------------------------- 1 | package com.mycompany.matrizenergeticas; 2 | 3 | import java.util.*; 4 | 5 | /** 6 | * 7 | * @author tomvargas 8 | */ 9 | public class main { 10 | public static void main(String args[]){ 11 | 12 | //scanner para entradas en consola 13 | Scanner in = new Scanner(System.in); 14 | 15 | //listas de ciudades para cada region 16 | ArrayList costa = new ArrayList(); 17 | costa.add("Guayaquil"); 18 | costa.add("Manta"); 19 | 20 | ArrayList sierra = new ArrayList(); 21 | sierra.add("Quito"); 22 | sierra.add("Ambato"); 23 | sierra.add("Loja"); 24 | 25 | ArrayList oriente = new ArrayList(); 26 | oriente.add("Tena"); 27 | oriente.add("Nueva Loja"); 28 | 29 | // diccionario de datos con la informción de cada region 30 | Dictionary informacion = new Hashtable(); 31 | informacion.put("costa", costa); 32 | informacion.put("sierra", sierra); 33 | informacion.put("oriente", oriente); 34 | 35 | //Lista de datos de consumos de quito en coca codo Sinclair 36 | ArrayList consumos_quito_ccs = new ArrayList(); 37 | consumos_quito_ccs.add(400); 38 | consumos_quito_ccs.add(432); 39 | consumos_quito_ccs.add(400); 40 | consumos_quito_ccs.add(432); 41 | consumos_quito_ccs.add(420); 42 | consumos_quito_ccs.add(432); 43 | consumos_quito_ccs.add(460); 44 | consumos_quito_ccs.add(432); 45 | consumos_quito_ccs.add(400); 46 | consumos_quito_ccs.add(432); 47 | consumos_quito_ccs.add(300); 48 | consumos_quito_ccs.add(213); 49 | 50 | //Lista de datos de consumos de guayaquil en coca codo Sinclair 51 | ArrayList consumos_gye_ccs = new ArrayList(); 52 | consumos_gye_ccs.add(120); 53 | consumos_gye_ccs.add(55); 54 | consumos_gye_ccs.add(32); 55 | consumos_gye_ccs.add(120); 56 | consumos_gye_ccs.add(75); 57 | consumos_gye_ccs.add(32); 58 | consumos_gye_ccs.add(150); 59 | consumos_gye_ccs.add(55); 60 | consumos_gye_ccs.add(32); 61 | consumos_gye_ccs.add(120); 62 | consumos_gye_ccs.add(97); 63 | consumos_gye_ccs.add(32); 64 | 65 | //Lista de datos de consumos de guayaquil en sopladora 66 | ArrayList consumos_gye_s = new ArrayList(); 67 | consumos_gye_s.add(310); 68 | consumos_gye_s.add(220); 69 | consumos_gye_s.add(321); 70 | consumos_gye_s.add(310); 71 | consumos_gye_s.add(220); 72 | consumos_gye_s.add(321); 73 | consumos_gye_s.add(310); 74 | consumos_gye_s.add(220); 75 | consumos_gye_s.add(321); 76 | consumos_gye_s.add(310); 77 | consumos_gye_s.add(220); 78 | consumos_gye_s.add(321); 79 | 80 | //Lista de datos de consumos de quito en sopladora 81 | ArrayList consumos_quito_s = new ArrayList(); 82 | consumos_quito_s.add(400); 83 | consumos_quito_s.add(432); 84 | consumos_quito_s.add(587); 85 | consumos_quito_s.add(400); 86 | consumos_quito_s.add(432); 87 | consumos_quito_s.add(587); 88 | consumos_quito_s.add(400); 89 | consumos_quito_s.add(432); 90 | consumos_quito_s.add(587); 91 | consumos_quito_s.add(400); 92 | consumos_quito_s.add(432); 93 | consumos_quito_s.add(587); 94 | 95 | //Lista de datos de consumos de loja en sopladora 96 | ArrayList consumos_loja_s = new ArrayList(); 97 | consumos_loja_s.add(50); 98 | consumos_loja_s.add(32); 99 | consumos_loja_s.add(32); 100 | consumos_loja_s.add(50); 101 | consumos_loja_s.add(32); 102 | consumos_loja_s.add(32); 103 | consumos_loja_s.add(50); 104 | consumos_loja_s.add(32); 105 | consumos_loja_s.add(32); 106 | consumos_loja_s.add(50); 107 | consumos_loja_s.add(32); 108 | consumos_loja_s.add(32); 109 | 110 | //Diccionario de datos con los consumos y tarifa de quito en CCS 111 | Dictionary CCS_QTO = new Hashtable(); 112 | CCS_QTO.put("consumos", consumos_quito_ccs); 113 | CCS_QTO.put("tarifa", 65); 114 | 115 | //Diccionario de datos con los consumos y tarifa de guayaquil en CCS 116 | Dictionary CCS_GYE = new Hashtable(); 117 | CCS_GYE.put("consumos", consumos_gye_ccs); 118 | CCS_GYE.put("tarifa", 84); 119 | 120 | //Diccionario de datos con los consumos y tarifa de Guayaquil en S 121 | Dictionary S_GYE = new Hashtable(); 122 | S_GYE.put("consumos", consumos_gye_s); 123 | S_GYE.put("tarifa", 55); 124 | 125 | //Diccionario de datos con los consumos y tarifa de Quito en S 126 | Dictionary S_QTO = new Hashtable(); 127 | S_QTO.put("consumos", consumos_quito_s); 128 | S_QTO.put("tarifa", 79); 129 | 130 | //Diccionario de datos con los consumos y tarifa de Loja en S 131 | Dictionary S_LJA = new Hashtable(); 132 | S_LJA.put("consumos", consumos_loja_s); 133 | S_LJA.put("tarifa", 32); 134 | 135 | 136 | //Diccionario con los datos de quito y guayaquil en CCS 137 | Dictionary CCS = new Hashtable(); 138 | CCS.put("Quito", CCS_QTO); 139 | CCS.put("Guayaquil", CCS_GYE); 140 | 141 | //Diccionario con los datos de quito, loja y guayaquil en S 142 | Dictionary S = new Hashtable(); 143 | S.put("Guayaquil", S_GYE); 144 | S.put("Quito", S_QTO); 145 | S.put("Loja", S_LJA); 146 | 147 | //Diccionario con los datos de CCS y S 148 | Dictionary consumo_energia = new Hashtable(); 149 | consumo_energia.put("Coca codo cinclair", CCS); 150 | consumo_energia.put("Sopladora", S); 151 | 152 | int aux = 1; 153 | 154 | while(aux==1){ 155 | 156 | System.out.println("===== MATRIZ ENERGETICA ====="); 157 | System.out.println("1) Consumo de planta."); 158 | System.out.println("2) Planta de cuidad."); 159 | System.out.println("3) Ganancias de region."); 160 | System.out.println("4) Salir del programa."); 161 | System.out.println(">> Seleccione una opcion: "); 162 | 163 | String op = in.nextLine(); 164 | 165 | switch(op){ 166 | case "1": 167 | System.out.println(">> Ingrese el nombre de la planta energetica: "); 168 | String planta = in.nextLine(); 169 | planta = planta.substring(0, 1).toUpperCase() + planta.substring(1); 170 | 171 | System.out.println(">> Ingrese el nombre de la ciudad: "); 172 | String ciudad = in.nextLine(); 173 | ciudad = ciudad.substring(0, 1).toUpperCase() + ciudad.substring(1); 174 | 175 | Dictionary Planta = (Dictionary) consumo_energia.get(planta); 176 | if(Planta != null){ 177 | Dictionary Ciudad = (Dictionary) Planta.get(ciudad); 178 | 179 | if(Ciudad != null){ 180 | ArrayList consumo = (ArrayList) Ciudad.get("consumos"); 181 | int total = 0; 182 | for (int i : consumo) { 183 | total += i; 184 | } 185 | System.out.println("Consumo de "+ciudad+" en "+planta+": "+total+" Megavatios.\n"); 186 | 187 | }else{ 188 | System.out.println(planta+" no suministra energia en esta ciudad"+" o no existe...\n"); 189 | } 190 | }else{ 191 | System.out.println("> No existe una planta energética con el nombre ingresado, vuelva a intentar...\n"); 192 | } 193 | 194 | break; 195 | 196 | case "2": 197 | 198 | System.out.println(">> Ingrese el nombre de la ciudad: "); 199 | String ciudad2 = in.nextLine(); 200 | ciudad2 = ciudad2.substring(0, 1).toUpperCase() + ciudad2.substring(1); 201 | 202 | Dictionary consumo_ciudad = new Hashtable(); 203 | String msj=""; 204 | 205 | Dictionary cocacodo1 = (Dictionary) consumo_energia.get("Coca codo cinclair"); 206 | Dictionary sopladora1 = (Dictionary) consumo_energia.get("Sopladora"); 207 | 208 | Dictionary ciudadCcs1 = (Dictionary) cocacodo1.get(ciudad2); 209 | if(ciudadCcs1 != null){ 210 | ArrayList consumo = (ArrayList) ciudadCcs1.get("consumos"); 211 | int tot = 0; 212 | for (int i : consumo) { 213 | tot += i; 214 | } 215 | consumo_ciudad.put("Coca codo cinclair",tot); 216 | msj=""; 217 | }else{ 218 | msj="No se administra energia a esta ciudad o no existe..."; 219 | } 220 | 221 | Dictionary ciudadS1 = (Dictionary) sopladora1.get(ciudad2); 222 | if(ciudadS1 != null){ 223 | ArrayList consumo = (ArrayList) ciudadS1.get("consumos"); 224 | int tot = 0; 225 | for (int i : consumo) { 226 | tot += i; 227 | } 228 | consumo_ciudad.put("Sopladora",tot); 229 | msj=""; 230 | }else{ 231 | msj="No se administra energia a esta ciudad o no existe..."; 232 | } 233 | 234 | if(!consumo_ciudad.isEmpty()){ 235 | System.out.println(consumo_ciudad); 236 | }else{ 237 | System.out.println(msj); 238 | } 239 | 240 | break; 241 | 242 | case "3": 243 | System.out.println(">> Ingrese el nombre de la region: "); 244 | String region = in.nextLine(); 245 | 246 | ArrayList Region = (ArrayList) informacion.get(region); 247 | if(Region != null){ 248 | int total = 0; 249 | Dictionary cocacodo = (Dictionary) consumo_energia.get("Coca codo cinclair"); 250 | Dictionary sopladora = (Dictionary) consumo_energia.get("Sopladora"); 251 | 252 | for (String i : Region) { 253 | 254 | Dictionary ciudadCcs = (Dictionary) cocacodo.get(i); 255 | Dictionary ciudadS = (Dictionary) sopladora.get(i); 256 | if(ciudadCcs != null){ 257 | ArrayList consumo = (ArrayList) ciudadCcs.get("consumos"); 258 | int tarifa = (int) ciudadCcs.get("tarifa"); 259 | int subtot = 0; 260 | for (int j : consumo) { 261 | subtot += j; 262 | } 263 | total += subtot*tarifa; 264 | } 265 | 266 | if(ciudadS != null){ 267 | ArrayList consumo = (ArrayList) ciudadS.get("consumos"); 268 | int tarifa = (int) ciudadS.get("tarifa"); 269 | int subtot = 0; 270 | for (int j : consumo) { 271 | subtot += j; 272 | } 273 | total += subtot*tarifa; 274 | } 275 | } 276 | 277 | System.out.println("Ganancias totales en la region "+region+": $"+total); 278 | 279 | }else{ 280 | System.out.println("> No existe una region con el nombre ingresado, vuelva a intentar...\n"); 281 | } 282 | 283 | break; 284 | case "4": 285 | aux=0; 286 | break; 287 | default: 288 | System.out.println("Entrada invalida, por favor ingrese una opcion valida...\n"); 289 | break; 290 | } 291 | } 292 | 293 | } 294 | } 295 | -------------------------------------------------------------------------------- /java/diccionarios-anidados/target/classes/com/mycompany/matrizenergeticas/main.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tomvargas/Programas/b6ae0cba3e20909b9a80ba0f09fd409e5942f67d/java/diccionarios-anidados/target/classes/com/mycompany/matrizenergeticas/main.class -------------------------------------------------------------------------------- /java/diccionarios-anidados/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst: -------------------------------------------------------------------------------- 1 | com\mycompany\matrizenergeticas\main.class 2 | -------------------------------------------------------------------------------- /java/diccionarios-anidados/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst: -------------------------------------------------------------------------------- 1 | C:\Users\User\Desktop\TOMVARGAS\ejercicios\java\matrizEnergeticas\src\main\java\com\mycompany\matrizenergeticas\main.java 2 | -------------------------------------------------------------------------------- /java/inmutabilidad/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | com.mycompany 5 | inmutabilidad 6 | 1.0-SNAPSHOT 7 | jar 8 | 9 | UTF-8 10 | 15 11 | 15 12 | 13 | -------------------------------------------------------------------------------- /java/inmutabilidad/src/main/java/com/mycompany/inmutabilidad/main.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package com.mycompany.inmutabilidad; 7 | 8 | /** 9 | * 10 | * @author User 11 | */ 12 | public class main { 13 | 14 | public static void main(String[] args) { 15 | // una variable text apunta a una string "Tomás" 16 | String text = "Tomás"; 17 | System.out.println(text); 18 | 19 | //Podemos intentar alterar esta string con métodos 20 | text.toUpperCase(); //esto debería hacer que toda la string cambie a mayusculas 21 | System.out.println(text); 22 | 23 | //aquí si se meustra la string en mayusculas 24 | System.out.println(text.toUpperCase()); 25 | 26 | // para hacer los cambios se guarden y no queden flotando en memoria 27 | text = text.toUpperCase(); 28 | System.out.println(text); 29 | 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /java/matrices.java: -------------------------------------------------------------------------------- 1 | import java.util.Random; 2 | import java.util.ArrayList; 3 | import java.util.Scanner; 4 | 5 | //@author tomvargas 6 | 7 | public class matrices { 8 | 9 | public static void main(String[] args) { 10 | 11 | Scanner get = new Scanner(System.in); 12 | int n=0, sum=0; 13 | ArrayList list = new ArrayList(); 14 | 15 | boolean val=true; 16 | 17 | while(val){ 18 | System.out.print(">> Ingresar la dimension de la matriz a generar: "); 19 | n = get.nextInt(); 20 | if (n>1 && n%2!=0){val=false;} 21 | else{System.out.println("La dimension de la matriz debe ser impar y mayor a uno.");} 22 | } 23 | 24 | int[][] matriz = new int[n][n]; 25 | 26 | for (int i=0; i < matriz.length; i++) { 27 | 28 | for (int j=0; j < matriz[i].length; j++) { 29 | 30 | matriz[i][j] = (int)(Math.random()*100+1); 31 | } 32 | } 33 | 34 | System.out.println(">> MATRIZ GENERADA: "); 35 | System.out.println("=================================="); 36 | 37 | for (int i=0; i < matriz.length; i++) { 38 | 39 | for (int j=0; j < matriz[i].length; j++) { 40 | 41 | System.out.print(matriz[i][j]+" "); 42 | } 43 | System.out.println(""); 44 | } 45 | 46 | System.out.println(">> BORDES: "); 47 | System.out.println("=================================="); 48 | 49 | for (int i=0; i < matriz.length; i++) { 50 | 51 | for (int j=0; j < matriz[i].length; j++) { 52 | 53 | if(i==0 || i==n-1){ 54 | 55 | System.out.print(matriz[i][j]+" "); 56 | list.add(matriz[i][j]); 57 | 58 | } 59 | else{ 60 | if(j==0 || j==n-1){ 61 | System.out.print(matriz[i][j]+" "); 62 | list.add(matriz[i][j]); 63 | for(int c=0;c> Numeros impares de la lista: "); 73 | for(int i:list){ 74 | sum+=i; 75 | if(i%2!=0){System.out.print(i+" ");} 76 | } 77 | System.out.println(""); 78 | System.out.println("=================================="); 79 | System.out.println(">> Promedio total de los bordes generados: "+(sum/list.size())); 80 | System.out.println(""); 81 | System.out.println("=================================="); 82 | System.out.println("@Author tomas_vargas"); 83 | System.out.println("=================================="); 84 | } 85 | } 86 | 87 | 88 | -------------------------------------------------------------------------------- /java/midespensa/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | com.mycompany 5 | midespensa 6 | 1.0-SNAPSHOT 7 | jar 8 | 9 | UTF-8 10 | 15 11 | 15 12 | 13 | -------------------------------------------------------------------------------- /java/midespensa/src/main/java/com/mycompany/midespensa/App.java: -------------------------------------------------------------------------------- 1 | package main.java; 2 | 3 | import javafx.application.Application; 4 | import javafx.fxml.FXMLLoader; 5 | import javafx.scene.Parent; 6 | import javafx.scene.Scene; 7 | import javafx.stage.Stage; 8 | 9 | import java.io.IOException; 10 | //import java.sql.*; 11 | 12 | /** 13 | * JavaFX App 14 | */ 15 | public class App extends Application { 16 | 17 | private static Scene scene; 18 | 19 | @Override 20 | public void start(Stage stage) throws IOException { 21 | scene = new Scene(loadFXML("clientes")); 22 | stage.setScene(scene); 23 | stage.show(); 24 | } 25 | 26 | public static void setRoot(String fxml) throws IOException { 27 | scene.setRoot(loadFXML(fxml)); 28 | } 29 | 30 | private static Parent loadFXML(String fxml) throws IOException { 31 | FXMLLoader fxmlLoader = new FXMLLoader(App.class.getResource("../resources/views/" + fxml + ".fxml")); 32 | return fxmlLoader.load(); 33 | } 34 | 35 | public static void main(String[] args) { 36 | launch(args); 37 | 38 | /* 39 | try { 40 | Connection conn = DBUtil.getConnection(); 41 | 42 | if (conn == null) System.out.println("is null"); 43 | // step3 create the statement object 44 | Statement stmt = conn.createStatement(); 45 | 46 | // step4 execute query 47 | ResultSet rs = stmt.executeQuery("SELECT * FROM CLIENTE"); 48 | 49 | while (rs.next()) { 50 | System.out.println(rs.getString(2)); 51 | } 52 | 53 | 54 | DBUtil.closeConnection(); 55 | } catch (SQLException e) { 56 | e.printStackTrace(); 57 | } 58 | */ 59 | } 60 | } -------------------------------------------------------------------------------- /java/midespensa/src/main/java/com/mycompany/midespensa/DBUtil.java: -------------------------------------------------------------------------------- 1 | package main.java; 2 | 3 | import java.sql.Connection; 4 | 5 | import java.sql.DriverManager; 6 | import java.sql.SQLException; 7 | 8 | public final class DBUtil { 9 | private static boolean isDriverLoaded = false; 10 | private static Connection con = null; 11 | static { 12 | try { 13 | Class.forName("oracle.jdbc.driver.OracleDriver"); 14 | System.out.println("Driver Loaded"); 15 | isDriverLoaded = true; 16 | } catch (ClassNotFoundException e) { 17 | e.printStackTrace(); 18 | } 19 | } 20 | 21 | private final static String url = "jdbc:oracle:thin:@//localhost:1521/xe"; 22 | private final static String user = "despensa"; 23 | private final static String password = "12345"; 24 | 25 | public static Connection getConnection() throws SQLException { 26 | if (isDriverLoaded && con == null) { 27 | try { 28 | con = DriverManager.getConnection(url, user, password); 29 | 30 | if (con != null) { 31 | System.out.println("Connected to the database!"); 32 | } else { 33 | System.out.println("Failed to make connection!"); 34 | } 35 | 36 | } catch (SQLException e) { 37 | System.err.format("SQL State: %s\n%s", e.getSQLState(), e.getMessage()); 38 | } catch (Exception e) { 39 | e.printStackTrace(); 40 | } 41 | } 42 | return con; 43 | } 44 | 45 | public static void closeConnection() throws SQLException { 46 | if (con != null) { 47 | con.close(); 48 | System.out.println("connection closed"); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /java/midespensa/src/main/java/com/mycompany/midespensa/Launch.java: -------------------------------------------------------------------------------- 1 | package main.java; 2 | 3 | public class Launch { 4 | // Replace "Main" with the name of the class that extends Application 5 | // See https://stackoverflow.com/a/52654791/3956070 for explanation 6 | public static void main(String[] args){ 7 | App.main(args); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /java/midespensa/src/main/java/com/mycompany/midespensa/classes/article.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package com.mycompany.midespensa.classes; 7 | 8 | /** 9 | * 10 | * @author User 11 | */ 12 | public class article { 13 | private int Id; 14 | private String Desc; 15 | private float Pvp; 16 | private float Price; 17 | private int Stock; 18 | private String Category; 19 | private String DateIn; 20 | private String CodeProv; 21 | 22 | public article(int Id, String Desc, float Pvp, float Price, int Stock, String Category, String DateIn, String CodeProv) { 23 | this.Id = Id; 24 | this.Desc = Desc; 25 | this.Pvp = Pvp; 26 | this.Price = Price; 27 | this.Stock = Stock; 28 | this.Category = Category; 29 | this.DateIn = DateIn; 30 | this.CodeProv = CodeProv; 31 | } 32 | 33 | public int getId() { 34 | return Id; 35 | } 36 | 37 | public void setId(int Id) { 38 | this.Id = Id; 39 | } 40 | 41 | public String getDesc() { 42 | return Desc; 43 | } 44 | 45 | public void setDesc(String Desc) { 46 | this.Desc = Desc; 47 | } 48 | 49 | public float getPvp() { 50 | return Pvp; 51 | } 52 | 53 | public void setPvp(float Pvp) { 54 | this.Pvp = Pvp; 55 | } 56 | 57 | public float getPrice() { 58 | return Price; 59 | } 60 | 61 | public void setPrice(float Price) { 62 | this.Price = Price; 63 | } 64 | 65 | public int getStock() { 66 | return Stock; 67 | } 68 | 69 | public void setStock(int Stock) { 70 | this.Stock = Stock; 71 | } 72 | 73 | public String getCategory() { 74 | return Category; 75 | } 76 | 77 | public void setCategory(String Category) { 78 | this.Category = Category; 79 | } 80 | 81 | public String getDateIn() { 82 | return DateIn; 83 | } 84 | 85 | public void setDateIn(String DateIn) { 86 | this.DateIn = DateIn; 87 | } 88 | 89 | public String getCodeProv() { 90 | return CodeProv; 91 | } 92 | 93 | public void setCodeProv(String CodeProv) { 94 | this.CodeProv = CodeProv; 95 | } 96 | 97 | 98 | } 99 | -------------------------------------------------------------------------------- /java/midespensa/src/main/java/com/mycompany/midespensa/classes/client.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package com.mycompany.midespensa.classes; 7 | 8 | /** 9 | * 10 | * @author User 11 | */ 12 | public class client extends persona { 13 | 14 | private String clientID; 15 | 16 | public client(String clientID, String NumDoc, String TipeDoc, String Name, String Surname, String CodCity, String Dir, String Phone) { 17 | super(NumDoc, TipeDoc, Name, Surname, CodCity, Dir, Phone); 18 | this.clientID = clientID; 19 | } 20 | 21 | public String getClientID() { 22 | return clientID; 23 | } 24 | 25 | public void setClientID(String clientID) { 26 | this.clientID = clientID; 27 | } 28 | 29 | 30 | 31 | } 32 | -------------------------------------------------------------------------------- /java/midespensa/src/main/java/com/mycompany/midespensa/classes/factura.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package com.mycompany.midespensa.classes; 7 | 8 | /** 9 | * 10 | * @author User 11 | */ 12 | public class factura { 13 | private String CodFac; 14 | private String empleadoID; 15 | private String clientID; 16 | private String DateFact; 17 | private String Pago; 18 | private float subtotal; 19 | private float total; 20 | 21 | public factura(String CodFac, String empleadoID, String clientID, String DateFact, String Pago, float subtotal, float total) { 22 | this.CodFac = CodFac; 23 | this.empleadoID = empleadoID; 24 | this.clientID = clientID; 25 | this.DateFact = DateFact; 26 | this.Pago = Pago; 27 | this.subtotal = subtotal; 28 | this.total = total; 29 | } 30 | 31 | public String getCodFac() { 32 | return CodFac; 33 | } 34 | 35 | public void setCodFac(String CodFac) { 36 | this.CodFac = CodFac; 37 | } 38 | 39 | public String getEmpleadoID() { 40 | return empleadoID; 41 | } 42 | 43 | public void setEmpleadoID(String empleadoID) { 44 | this.empleadoID = empleadoID; 45 | } 46 | 47 | public String getClientID() { 48 | return clientID; 49 | } 50 | 51 | public void setClientID(String clientID) { 52 | this.clientID = clientID; 53 | } 54 | 55 | public String getDateFact() { 56 | return DateFact; 57 | } 58 | 59 | public void setDateFact(String DateFact) { 60 | this.DateFact = DateFact; 61 | } 62 | 63 | public String getPago() { 64 | return Pago; 65 | } 66 | 67 | public void setPago(String Pago) { 68 | this.Pago = Pago; 69 | } 70 | 71 | public float getSubtotal() { 72 | return subtotal; 73 | } 74 | 75 | public void setSubtotal(float subtotal) { 76 | this.subtotal = subtotal; 77 | } 78 | 79 | public float getTotal() { 80 | return total; 81 | } 82 | 83 | public void setTotal(float total) { 84 | this.total = total; 85 | } 86 | 87 | 88 | } 89 | -------------------------------------------------------------------------------- /java/midespensa/src/main/java/com/mycompany/midespensa/classes/persona.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package com.mycompany.midespensa.classes; 7 | 8 | /** 9 | * 10 | * @author User 11 | */ 12 | public class persona { 13 | private String NumDoc; 14 | private String TipeDoc; 15 | private String Name; 16 | private String Surname; 17 | private String CodCity; 18 | private String Dir; 19 | private String Phone; 20 | 21 | public persona(String NumDoc, String TipeDoc, String Name, String Surname, String CodCity, String Dir, String Phone) { 22 | this.NumDoc = NumDoc; 23 | this.TipeDoc = TipeDoc; 24 | this.Name = Name; 25 | this.Surname = Surname; 26 | this.CodCity = CodCity; 27 | this.Dir = Dir; 28 | this.Phone = Phone; 29 | } 30 | 31 | public String getNumDoc() { return NumDoc; } 32 | public void setNumDoc(String NumDoc) { this.NumDoc = NumDoc; } 33 | 34 | public String getTipeDoc() { return TipeDoc; } 35 | public void setTipeDoc(String TipeDoc) { this.TipeDoc = TipeDoc; } 36 | 37 | public String getName() { return Name; } 38 | public void setName(String Name) { this.Name = Name; } 39 | 40 | public String getSurname() { return Surname; } 41 | public void setSurname(String Surname) { this.Surname = Surname; } 42 | 43 | public String getCodCity() { return CodCity; } 44 | public void setCodCity(String CodCity) { this.CodCity = CodCity; } 45 | 46 | public String getDir() { return Dir; } 47 | public void setDir(String Dir) { this.Dir = Dir; } 48 | 49 | public String getPhone() { return Phone; } 50 | public void setPhone(String Phone) { this.Phone = Phone; } 51 | 52 | 53 | } 54 | -------------------------------------------------------------------------------- /java/midespensa/src/main/java/com/mycompany/midespensa/classes/proveedor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package com.mycompany.midespensa.classes; 7 | 8 | /** 9 | * 10 | * @author User 11 | */ 12 | public class proveedor extends persona { 13 | private String NameCommerce; 14 | private String CodProv; 15 | 16 | public proveedor(String NameCommerce, String CodProd, String NumDoc, String TipeDoc, String Name, String Surname, String CodCity, String Dir, String Phone) { 17 | super(NumDoc, TipeDoc, Name, Surname, CodCity, Dir, Phone); 18 | this.NameCommerce = NameCommerce; 19 | this.CodProv = CodProv; 20 | } 21 | 22 | public String getNameCommerce() { return NameCommerce; } 23 | public void setNameCommerce(String NameCommerce) { this.NameCommerce = NameCommerce; } 24 | 25 | public String getCodProv() { return CodProv; } 26 | public void setCodProv(String CodProv) { this.CodProv = CodProv; } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /java/midespensa/src/main/java/com/mycompany/midespensa/controllers/clientController.java: -------------------------------------------------------------------------------- 1 | package main.java.controllers; 2 | 3 | // REPOSITORIES 4 | import main.java.repositories.ClientRepository; 5 | 6 | // MODELS 7 | import main.java.models.Clients; 8 | 9 | import java.net.URL; 10 | import java.util.ResourceBundle; 11 | import javafx.collections.FXCollections; 12 | import javafx.collections.ObservableList; 13 | import javafx.fxml.FXML; 14 | import javafx.fxml.Initializable; 15 | import javafx.scene.control.TableColumn; 16 | import javafx.scene.control.TableView; 17 | import javafx.scene.control.cell.PropertyValueFactory; 18 | 19 | public class clientController implements Initializable { 20 | @FXML private TableView tb_client; 21 | @FXML private TableColumn col_idDoc; 22 | @FXML private TableColumn col_A1; 23 | @FXML private TableColumn col_A2; 24 | @FXML private TableColumn col_nom; 25 | @FXML private TableColumn col_dir; 26 | @FXML private TableColumn col_telf; 27 | 28 | @Override 29 | public void initialize(URL location, ResourceBundle resources) { 30 | ObservableList data = FXCollections.observableArrayList(ClientRepository.getAll()); 31 | 32 | col_idDoc.setCellValueFactory(new PropertyValueFactory("id")); 33 | col_A1.setCellValueFactory(new PropertyValueFactory("a1")); 34 | col_A2.setCellValueFactory(new PropertyValueFactory("a2")); 35 | col_nom.setCellValueFactory(new PropertyValueFactory("nom")); 36 | col_dir.setCellValueFactory(new PropertyValueFactory("dir")); 37 | col_telf.setCellValueFactory(new PropertyValueFactory("telf")); 38 | 39 | tb_client.setItems(data); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /java/midespensa/src/main/java/com/mycompany/midespensa/controllers/mainController.java: -------------------------------------------------------------------------------- 1 | package main.java.controllers; 2 | 3 | import java.io.IOException; 4 | 5 | import javafx.event.ActionEvent; 6 | import javafx.fxml.FXML; 7 | import javafx.scene.control.Button; 8 | import main.java.App; 9 | 10 | public class mainController { 11 | 12 | @FXML private Button btn_clientes; 13 | @FXML private Button btn_productos; 14 | @FXML private Button btn_comprar; 15 | 16 | @FXML 17 | void onClick(ActionEvent event) { 18 | try { 19 | App.setRoot("primary"); 20 | } catch (IOException e) { 21 | e.printStackTrace(); 22 | } 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /java/midespensa/src/main/java/com/mycompany/midespensa/models/Clients.java: -------------------------------------------------------------------------------- 1 | package main.java.models; 2 | 3 | import javafx.beans.property.SimpleStringProperty; 4 | 5 | public class Clients { 6 | private SimpleStringProperty id, a1, a2, nom, dir, telf; 7 | 8 | public Clients(String id, String a1, String a2, String nom, String dir, String telf) { 9 | this.id = new SimpleStringProperty(id); 10 | this.a1 = new SimpleStringProperty(a1); 11 | this.a2 = new SimpleStringProperty(a2); 12 | this.nom = new SimpleStringProperty(nom); 13 | this.dir = new SimpleStringProperty(dir); 14 | this.telf = new SimpleStringProperty(telf); 15 | } 16 | 17 | public String getId() { 18 | return id.get(); 19 | } 20 | 21 | public void setId(String p) { 22 | id.set(p); 23 | } 24 | 25 | public String getA1() { 26 | return a1.get(); 27 | } 28 | 29 | public void setA1(String p) { 30 | a1.set(p); 31 | } 32 | 33 | public String getA2() { 34 | return a2.get(); 35 | } 36 | 37 | public void setA2(String p) { 38 | a2.set(p); 39 | } 40 | 41 | public String getNom() { 42 | return nom.get(); 43 | } 44 | 45 | public void setNom(String p) { 46 | nom.set(p); 47 | } 48 | 49 | public String getDir() { 50 | return dir.get(); 51 | } 52 | 53 | public void setDir(String p) { 54 | dir.set(p); 55 | } 56 | 57 | public String getTelf() { 58 | return telf.get(); 59 | } 60 | 61 | public void setTelf(String p) { 62 | telf.set(p); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /java/midespensa/src/main/java/com/mycompany/midespensa/repositories/ClientRepository.java: -------------------------------------------------------------------------------- 1 | package main.java.repositories; 2 | 3 | // MODELS 4 | import main.java.models.Clients; 5 | 6 | // SQL 7 | import java.sql.ResultSet; 8 | import java.sql.SQLException; 9 | 10 | // DATABASE 11 | import main.java.DBUtil; 12 | 13 | import java.util.ArrayList; 14 | 15 | public final class ClientRepository { 16 | public static ArrayList getAll() { 17 | ArrayList data = new ArrayList<>(); 18 | try { 19 | ResultSet rs = DBUtil.getConnection() 20 | .createStatement() 21 | .executeQuery("SELECT * FROM CLIENTE"); 22 | 23 | while (rs.next()) { 24 | data.add(new Clients( 25 | rs.getString(2), 26 | rs.getString(3), 27 | rs.getString(4), 28 | rs.getString(5), 29 | rs.getString(6), 30 | rs.getString(7) 31 | )); 32 | } 33 | 34 | } catch (SQLException e) { 35 | e.printStackTrace(); 36 | } 37 | return data; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /java/midespensa/src/main/java/com/mycompany/midespensa/screens/addclient.form: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /java/midespensa/src/main/java/com/mycompany/midespensa/screens/addclient.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package com.mycompany.midespensa.screens; 7 | 8 | import javax.swing.JFrame; 9 | 10 | /** 11 | * 12 | * @author User 13 | */ 14 | public class addclient extends javax.swing.JFrame { 15 | 16 | /** 17 | * Creates new form addclient 18 | */ 19 | public addclient() { 20 | initComponents(); 21 | this.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); 22 | } 23 | 24 | /** 25 | * This method is called from within the constructor to initialize the form. 26 | * WARNING: Do NOT modify this code. The content of this method is always 27 | * regenerated by the Form Editor. 28 | */ 29 | @SuppressWarnings("unchecked") 30 | // //GEN-BEGIN:initComponents 31 | private void initComponents() { 32 | 33 | jLabel1 = new javax.swing.JLabel(); 34 | 35 | setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); 36 | 37 | jLabel1.setFont(new java.awt.Font("Century Gothic", 1, 24)); // NOI18N 38 | jLabel1.setText("AGREGAR CLIENTE"); 39 | 40 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); 41 | getContentPane().setLayout(layout); 42 | layout.setHorizontalGroup( 43 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 44 | .addGroup(layout.createSequentialGroup() 45 | .addGap(85, 85, 85) 46 | .addComponent(jLabel1) 47 | .addContainerGap(103, Short.MAX_VALUE)) 48 | ); 49 | layout.setVerticalGroup( 50 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 51 | .addGroup(layout.createSequentialGroup() 52 | .addGap(20, 20, 20) 53 | .addComponent(jLabel1) 54 | .addContainerGap(249, Short.MAX_VALUE)) 55 | ); 56 | 57 | pack(); 58 | }// //GEN-END:initComponents 59 | 60 | 61 | 62 | // Variables declaration - do not modify//GEN-BEGIN:variables 63 | private javax.swing.JLabel jLabel1; 64 | // End of variables declaration//GEN-END:variables 65 | } 66 | -------------------------------------------------------------------------------- /java/midespensa/src/main/java/com/mycompany/midespensa/screens/addprod.form: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /java/midespensa/src/main/java/com/mycompany/midespensa/screens/addprod.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package com.mycompany.midespensa.screens; 7 | 8 | import javax.swing.JFrame; 9 | 10 | /** 11 | * 12 | * @author User 13 | */ 14 | public class addprod extends javax.swing.JFrame { 15 | 16 | /** 17 | * Creates new form addprod 18 | */ 19 | public addprod() { 20 | initComponents(); 21 | this.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); 22 | } 23 | 24 | /** 25 | * This method is called from within the constructor to initialize the form. 26 | * WARNING: Do NOT modify this code. The content of this method is always 27 | * regenerated by the Form Editor. 28 | */ 29 | @SuppressWarnings("unchecked") 30 | // //GEN-BEGIN:initComponents 31 | private void initComponents() { 32 | 33 | jLabel1 = new javax.swing.JLabel(); 34 | 35 | setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); 36 | 37 | jLabel1.setFont(new java.awt.Font("Century Gothic", 1, 24)); // NOI18N 38 | jLabel1.setText("AGREGAR PRODUCTO"); 39 | 40 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); 41 | getContentPane().setLayout(layout); 42 | layout.setHorizontalGroup( 43 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 44 | .addGroup(layout.createSequentialGroup() 45 | .addGap(70, 70, 70) 46 | .addComponent(jLabel1) 47 | .addContainerGap(81, Short.MAX_VALUE)) 48 | ); 49 | layout.setVerticalGroup( 50 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 51 | .addGroup(layout.createSequentialGroup() 52 | .addGap(20, 20, 20) 53 | .addComponent(jLabel1) 54 | .addContainerGap(249, Short.MAX_VALUE)) 55 | ); 56 | 57 | pack(); 58 | }// //GEN-END:initComponents 59 | 60 | // Variables declaration - do not modify//GEN-BEGIN:variables 61 | private javax.swing.JLabel jLabel1; 62 | // End of variables declaration//GEN-END:variables 63 | } 64 | -------------------------------------------------------------------------------- /java/midespensa/src/main/java/com/mycompany/midespensa/screens/clientes.form: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | -------------------------------------------------------------------------------- /java/midespensa/src/main/java/com/mycompany/midespensa/screens/clientes.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package com.mycompany.midespensa.screens; 7 | 8 | import java.util.ArrayList; 9 | import javax.swing.JFrame; 10 | import javax.swing.JLabel; 11 | import com.mycompany.midespensa.classes.client; 12 | 13 | /** 14 | * 15 | * @author User 16 | */ 17 | public class clientes extends javax.swing.JFrame { 18 | 19 | 20 | public clientes() { 21 | initComponents(); 22 | this.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); 23 | 24 | } 25 | 26 | public ArrayList getCli(){ 27 | ArrayList list = new ArrayList(); 28 | client c1 = new client("01", "0987456789", "CI", "Tomás", "Vargas", "593", "Guayaquil", "0967545678"); 29 | 30 | list.add(c1); 31 | 32 | return list; 33 | } 34 | 35 | /** 36 | * This method is called from within the constructor to initialize the form. 37 | * WARNING: Do NOT modify this code. The content of this method is always 38 | * regenerated by the Form Editor. 39 | */ 40 | @SuppressWarnings("unchecked") 41 | // //GEN-BEGIN:initComponents 42 | private void initComponents() { 43 | 44 | jLabel1 = new javax.swing.JLabel(); 45 | jScrollPane2 = new javax.swing.JScrollPane(); 46 | jList2 = new javax.swing.JList<>(); 47 | 48 | setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); 49 | 50 | jLabel1.setFont(new java.awt.Font("Century Gothic", 1, 24)); // NOI18N 51 | jLabel1.setText("CLIENTES"); 52 | 53 | jList2.setModel(new javax.swing.AbstractListModel() { 54 | String[] strings = { "TOMÁS", "RONALDO", "SERGIO", "KENTH", "DAYANA", "CRISTOPHER" }; 55 | public int getSize() { return strings.length; } 56 | public String getElementAt(int i) { return strings[i]; } 57 | }); 58 | jScrollPane2.setViewportView(jList2); 59 | 60 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); 61 | getContentPane().setLayout(layout); 62 | layout.setHorizontalGroup( 63 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 64 | .addGroup(layout.createSequentialGroup() 65 | .addGap(131, 131, 131) 66 | .addComponent(jLabel1) 67 | .addContainerGap(122, Short.MAX_VALUE)) 68 | .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() 69 | .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 70 | .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 240, javax.swing.GroupLayout.PREFERRED_SIZE) 71 | .addGap(45, 45, 45)) 72 | ); 73 | layout.setVerticalGroup( 74 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 75 | .addGroup(layout.createSequentialGroup() 76 | .addGap(27, 27, 27) 77 | .addComponent(jLabel1) 78 | .addGap(18, 18, 18) 79 | .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 270, javax.swing.GroupLayout.PREFERRED_SIZE) 80 | .addContainerGap(51, Short.MAX_VALUE)) 81 | ); 82 | 83 | pack(); 84 | }// //GEN-END:initComponents 85 | 86 | 87 | 88 | // Variables declaration - do not modify//GEN-BEGIN:variables 89 | private javax.swing.JLabel jLabel1; 90 | private javax.swing.JList jList2; 91 | private javax.swing.JScrollPane jScrollPane2; 92 | // End of variables declaration//GEN-END:variables 93 | } 94 | -------------------------------------------------------------------------------- /java/midespensa/src/main/java/com/mycompany/midespensa/screens/factura.form: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /java/midespensa/src/main/java/com/mycompany/midespensa/screens/factura.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package com.mycompany.midespensa.screens; 7 | 8 | import javax.swing.JFrame; 9 | 10 | /** 11 | * 12 | * @author User 13 | */ 14 | public class factura extends javax.swing.JFrame { 15 | 16 | /** 17 | * Creates new form factura 18 | */ 19 | public factura() { 20 | initComponents(); 21 | this.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); 22 | } 23 | 24 | /** 25 | * This method is called from within the constructor to initialize the form. 26 | * WARNING: Do NOT modify this code. The content of this method is always 27 | * regenerated by the Form Editor. 28 | */ 29 | @SuppressWarnings("unchecked") 30 | // //GEN-BEGIN:initComponents 31 | private void initComponents() { 32 | 33 | jLabel1 = new javax.swing.JLabel(); 34 | 35 | setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); 36 | 37 | jLabel1.setFont(new java.awt.Font("Century Gothic", 1, 24)); // NOI18N 38 | jLabel1.setText("FACTURA"); 39 | 40 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); 41 | getContentPane().setLayout(layout); 42 | layout.setHorizontalGroup( 43 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 44 | .addGroup(layout.createSequentialGroup() 45 | .addGap(142, 142, 142) 46 | .addComponent(jLabel1) 47 | .addContainerGap(152, Short.MAX_VALUE)) 48 | ); 49 | layout.setVerticalGroup( 50 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 51 | .addGroup(layout.createSequentialGroup() 52 | .addGap(27, 27, 27) 53 | .addComponent(jLabel1) 54 | .addContainerGap(242, Short.MAX_VALUE)) 55 | ); 56 | 57 | pack(); 58 | }// //GEN-END:initComponents 59 | 60 | 61 | 62 | // Variables declaration - do not modify//GEN-BEGIN:variables 63 | private javax.swing.JLabel jLabel1; 64 | // End of variables declaration//GEN-END:variables 65 | } 66 | -------------------------------------------------------------------------------- /java/midespensa/src/main/java/com/mycompany/midespensa/screens/home.form: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | -------------------------------------------------------------------------------- /java/midespensa/src/main/java/com/mycompany/midespensa/screens/home.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package com.mycompany.midespensa.screens; 7 | 8 | /** 9 | * 10 | * @author User 11 | */ 12 | public class home extends javax.swing.JFrame { 13 | 14 | /** 15 | * Creates new form home 16 | */ 17 | public home() { 18 | initComponents(); 19 | } 20 | 21 | /** 22 | * This method is called from within the constructor to initialize the form. 23 | * WARNING: Do NOT modify this code. The content of this method is always 24 | * regenerated by the Form Editor. 25 | */ 26 | @SuppressWarnings("unchecked") 27 | // //GEN-BEGIN:initComponents 28 | private void initComponents() { 29 | 30 | jLabel1 = new javax.swing.JLabel(); 31 | jButton1 = new javax.swing.JButton(); 32 | jButton3 = new javax.swing.JButton(); 33 | jButton4 = new javax.swing.JButton(); 34 | 35 | setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); 36 | 37 | jLabel1.setFont(new java.awt.Font("Century Gothic", 1, 24)); // NOI18N 38 | jLabel1.setText("DESPENSA VIRTUAL"); 39 | 40 | jButton1.setText("CLIENTES"); 41 | jButton1.addActionListener(new java.awt.event.ActionListener() { 42 | public void actionPerformed(java.awt.event.ActionEvent evt) { 43 | jButton1ActionPerformed(evt); 44 | } 45 | }); 46 | 47 | jButton3.setText("PRODUCTOS"); 48 | jButton3.addActionListener(new java.awt.event.ActionListener() { 49 | public void actionPerformed(java.awt.event.ActionEvent evt) { 50 | jButton3ActionPerformed(evt); 51 | } 52 | }); 53 | 54 | jButton4.setText("COMPRAR"); 55 | jButton4.addActionListener(new java.awt.event.ActionListener() { 56 | public void actionPerformed(java.awt.event.ActionEvent evt) { 57 | jButton4ActionPerformed(evt); 58 | } 59 | }); 60 | 61 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); 62 | getContentPane().setLayout(layout); 63 | layout.setHorizontalGroup( 64 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 65 | .addGroup(layout.createSequentialGroup() 66 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 67 | .addGroup(layout.createSequentialGroup() 68 | .addGap(16, 16, 16) 69 | .addComponent(jLabel1)) 70 | .addGroup(layout.createSequentialGroup() 71 | .addGap(66, 66, 66) 72 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) 73 | .addComponent(jButton3) 74 | .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE) 75 | .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE)))) 76 | .addContainerGap(16, Short.MAX_VALUE)) 77 | ); 78 | layout.setVerticalGroup( 79 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 80 | .addGroup(layout.createSequentialGroup() 81 | .addGap(14, 14, 14) 82 | .addComponent(jLabel1) 83 | .addGap(28, 28, 28) 84 | .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE) 85 | .addGap(18, 18, 18) 86 | .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE) 87 | .addGap(18, 18, 18) 88 | .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE) 89 | .addContainerGap(28, Short.MAX_VALUE)) 90 | ); 91 | 92 | pack(); 93 | }// //GEN-END:initComponents 94 | 95 | private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed 96 | // TODO add your handling code here: 97 | new clientes().setVisible(true); 98 | }//GEN-LAST:event_jButton1ActionPerformed 99 | 100 | private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed 101 | // TODO add your handling code here: 102 | new productos().setVisible(true); 103 | }//GEN-LAST:event_jButton3ActionPerformed 104 | 105 | private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed 106 | // TODO add your handling code here: 107 | new compra().setVisible(true); 108 | }//GEN-LAST:event_jButton4ActionPerformed 109 | 110 | // Variables declaration - do not modify//GEN-BEGIN:variables 111 | private javax.swing.JButton jButton1; 112 | private javax.swing.JButton jButton3; 113 | private javax.swing.JButton jButton4; 114 | private javax.swing.JLabel jLabel1; 115 | // End of variables declaration//GEN-END:variables 116 | } 117 | -------------------------------------------------------------------------------- /java/midespensa/src/main/java/com/mycompany/midespensa/screens/main.form: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | -------------------------------------------------------------------------------- /java/midespensa/src/main/java/com/mycompany/midespensa/screens/main.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package com.mycompany.midespensa.screens; 7 | 8 | import javax.swing.JOptionPane; 9 | 10 | /** 11 | * 12 | * @author User 13 | */ 14 | public class main extends javax.swing.JFrame { 15 | 16 | /** 17 | * Creates new form main 18 | */ 19 | public main() { 20 | initComponents(); 21 | } 22 | 23 | /** 24 | * This method is called from within the constructor to initialize the form. 25 | * WARNING: Do NOT modify this code. The content of this method is always 26 | * regenerated by the Form Editor. 27 | */ 28 | @SuppressWarnings("unchecked") 29 | // //GEN-BEGIN:initComponents 30 | private void initComponents() { 31 | 32 | jLabel1 = new javax.swing.JLabel(); 33 | jLabel2 = new javax.swing.JLabel(); 34 | btnlogin = new javax.swing.JButton(); 35 | btnregister = new javax.swing.JButton(); 36 | txtuser = new javax.swing.JTextField(); 37 | txtpass = new javax.swing.JTextField(); 38 | jLabel3 = new javax.swing.JLabel(); 39 | jLabel4 = new javax.swing.JLabel(); 40 | jLabel5 = new javax.swing.JLabel(); 41 | 42 | setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); 43 | 44 | jLabel1.setFont(new java.awt.Font("Century Gothic", 1, 48)); // NOI18N 45 | jLabel1.setText("DV"); 46 | 47 | jLabel2.setText("DESPENSA VIRTUAL"); 48 | 49 | btnlogin.setText("INICIAR SESIÓN"); 50 | btnlogin.addActionListener(new java.awt.event.ActionListener() { 51 | public void actionPerformed(java.awt.event.ActionEvent evt) { 52 | btnloginActionPerformed(evt); 53 | } 54 | }); 55 | 56 | btnregister.setText("REGISTRARSE"); 57 | btnregister.addActionListener(new java.awt.event.ActionListener() { 58 | public void actionPerformed(java.awt.event.ActionEvent evt) { 59 | btnregisterActionPerformed(evt); 60 | } 61 | }); 62 | 63 | txtuser.setToolTipText(""); 64 | txtuser.addActionListener(new java.awt.event.ActionListener() { 65 | public void actionPerformed(java.awt.event.ActionEvent evt) { 66 | txtuserActionPerformed(evt); 67 | } 68 | }); 69 | 70 | txtpass.addActionListener(new java.awt.event.ActionListener() { 71 | public void actionPerformed(java.awt.event.ActionEvent evt) { 72 | txtpassActionPerformed(evt); 73 | } 74 | }); 75 | 76 | jLabel3.setText("CONTRASEÑA"); 77 | 78 | jLabel4.setText("USUARIO"); 79 | 80 | jLabel5.setText("SOF-S-MA-4-1-D"); 81 | 82 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); 83 | getContentPane().setLayout(layout); 84 | layout.setHorizontalGroup( 85 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 86 | .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() 87 | .addContainerGap(74, Short.MAX_VALUE) 88 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 89 | .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() 90 | .addComponent(jLabel2) 91 | .addGap(99, 99, 99)) 92 | .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() 93 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 94 | .addComponent(jLabel3) 95 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) 96 | .addComponent(txtpass, javax.swing.GroupLayout.PREFERRED_SIZE, 188, javax.swing.GroupLayout.PREFERRED_SIZE) 97 | .addComponent(txtuser, javax.swing.GroupLayout.PREFERRED_SIZE, 188, javax.swing.GroupLayout.PREFERRED_SIZE)) 98 | .addComponent(jLabel4)) 99 | .addGap(63, 63, 63)) 100 | .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() 101 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) 102 | .addComponent(btnregister, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 103 | .addComponent(btnlogin, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) 104 | .addGap(101, 101, 101)))) 105 | .addGroup(layout.createSequentialGroup() 106 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 107 | .addGroup(layout.createSequentialGroup() 108 | .addGap(129, 129, 129) 109 | .addComponent(jLabel1)) 110 | .addGroup(layout.createSequentialGroup() 111 | .addContainerGap() 112 | .addComponent(jLabel5))) 113 | .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) 114 | ); 115 | layout.setVerticalGroup( 116 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 117 | .addGroup(layout.createSequentialGroup() 118 | .addGap(33, 33, 33) 119 | .addComponent(jLabel1) 120 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) 121 | .addComponent(jLabel2) 122 | .addGap(23, 23, 23) 123 | .addComponent(jLabel4) 124 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 125 | .addComponent(txtuser, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 126 | .addGap(18, 18, 18) 127 | .addComponent(jLabel3) 128 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 129 | .addComponent(txtpass, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 130 | .addGap(35, 35, 35) 131 | .addComponent(btnlogin) 132 | .addGap(18, 18, 18) 133 | .addComponent(btnregister) 134 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 25, Short.MAX_VALUE) 135 | .addComponent(jLabel5) 136 | .addContainerGap()) 137 | ); 138 | 139 | pack(); 140 | }// //GEN-END:initComponents 141 | 142 | private void btnloginActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnloginActionPerformed 143 | // TODO add your handling code here: 144 | String UserName = txtuser.getText().trim(); 145 | String UserPass = txtpass.getText().trim(); 146 | 147 | //----------------------------------------------------------------------code for get DB data (user - pass) 148 | 149 | if (UserName == "user" && UserPass == "pass"){ 150 | this.setVisible(false); 151 | new home().setVisible(true); 152 | } 153 | else{ 154 | //JOptionPane.showMessageDialog(null,"Usuario o contraseña incorrecta"); 155 | this.setVisible(false); 156 | new home().setVisible(true); 157 | } 158 | }//GEN-LAST:event_btnloginActionPerformed 159 | 160 | private void btnregisterActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnregisterActionPerformed 161 | // TODO add your handling code here: 162 | String UserName = txtuser.getText().trim(); 163 | String UserPass = txtpass.getText().trim(); 164 | 165 | //---------------------------------------------------------------------- code for save data in DB 166 | }//GEN-LAST:event_btnregisterActionPerformed 167 | 168 | private void txtpassActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtpassActionPerformed 169 | // TODO add your handling code here: 170 | }//GEN-LAST:event_txtpassActionPerformed 171 | 172 | private void txtuserActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtuserActionPerformed 173 | // TODO add your handling code here: 174 | }//GEN-LAST:event_txtuserActionPerformed 175 | 176 | /** 177 | * @param args the command line arguments 178 | */ 179 | public static void main(String args[]) { 180 | /* Set the Nimbus look and feel */ 181 | // 182 | /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. 183 | * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 184 | */ 185 | try { 186 | for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { 187 | if ("Nimbus".equals(info.getName())) { 188 | javax.swing.UIManager.setLookAndFeel(info.getClassName()); 189 | break; 190 | } 191 | } 192 | } catch (ClassNotFoundException ex) { 193 | java.util.logging.Logger.getLogger(main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 194 | } catch (InstantiationException ex) { 195 | java.util.logging.Logger.getLogger(main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 196 | } catch (IllegalAccessException ex) { 197 | java.util.logging.Logger.getLogger(main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 198 | } catch (javax.swing.UnsupportedLookAndFeelException ex) { 199 | java.util.logging.Logger.getLogger(main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 200 | } 201 | // 202 | 203 | /* Create and display the form */ 204 | java.awt.EventQueue.invokeLater(new Runnable() { 205 | public void run() { 206 | new main().setVisible(true); 207 | } 208 | }); 209 | } 210 | 211 | // Variables declaration - do not modify//GEN-BEGIN:variables 212 | private javax.swing.JButton btnlogin; 213 | private javax.swing.JButton btnregister; 214 | private javax.swing.JLabel jLabel1; 215 | private javax.swing.JLabel jLabel2; 216 | private javax.swing.JLabel jLabel3; 217 | private javax.swing.JLabel jLabel4; 218 | private javax.swing.JLabel jLabel5; 219 | private javax.swing.JTextField txtpass; 220 | private javax.swing.JTextField txtuser; 221 | // End of variables declaration//GEN-END:variables 222 | } 223 | -------------------------------------------------------------------------------- /java/midespensa/src/main/java/com/mycompany/midespensa/screens/productos.form: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 |
79 |
80 | 81 | 82 | 83 | 84 | <Editor/> 85 | <Renderer/> 86 | </Column> 87 | <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> 88 | <Title/> 89 | <Editor/> 90 | <Renderer/> 91 | </Column> 92 | <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> 93 | <Title/> 94 | <Editor/> 95 | <Renderer/> 96 | </Column> 97 | <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> 98 | <Title/> 99 | <Editor/> 100 | <Renderer/> 101 | </Column> 102 | <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> 103 | <Title/> 104 | <Editor/> 105 | <Renderer/> 106 | </Column> 107 | <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> 108 | <Title/> 109 | <Editor/> 110 | <Renderer/> 111 | </Column> 112 | <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> 113 | <Title/> 114 | <Editor/> 115 | <Renderer/> 116 | </Column> 117 | <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> 118 | <Title/> 119 | <Editor/> 120 | <Renderer/> 121 | </Column> 122 | </TableColumnModel> 123 | </Property> 124 | <Property name="tableHeader" type="javax.swing.table.JTableHeader" editor="org.netbeans.modules.form.editors2.JTableHeaderEditor"> 125 | <TableHeader reorderingAllowed="true" resizingAllowed="true"/> 126 | </Property> 127 | </Properties> 128 | </Component> 129 | </SubComponents> 130 | </Container> 131 | </SubComponents> 132 | </Form> 133 | -------------------------------------------------------------------------------- /java/midespensa/src/main/java/com/mycompany/midespensa/screens/productos.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package com.mycompany.midespensa.screens; 7 | 8 | import javax.swing.JFrame; 9 | import com.mycompany.midespensa.classes.article; 10 | import java.util.ArrayList; 11 | import javax.swing.table.DefaultTableModel; 12 | 13 | /** 14 | * 15 | * @author User 16 | */ 17 | public class productos extends javax.swing.JFrame { 18 | 19 | /** 20 | * 21 | */ 22 | public productos() { 23 | initComponents(); 24 | this.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); 25 | addRowToJTable(); 26 | } 27 | 28 | public ArrayList ListProducts() 29 | { 30 | ArrayList<article> list = new ArrayList<article>(); 31 | article P1 = new article(1, "Atun", (float)1.50, (float)0.75, 300, "Alimento", "01-09-2021", "001"); 32 | article P2 = new article(2, "Cereal", (float)3.99, (float)1.75, 100, "Alimento", "01-09-2021", "003"); 33 | article P3 = new article(3, "Lámpara", (float)10, (float)6.95, 80, "Hogar", "04-09-2021", "002"); 34 | list.add(P1); 35 | list.add(P2); 36 | list.add(P3); 37 | 38 | return list; 39 | } 40 | 41 | public void addRowToJTable() 42 | { 43 | DefaultTableModel model = (DefaultTableModel) jTable1.getModel(); 44 | ArrayList<article> list = ListProducts(); 45 | Object rowData[] = new Object[8]; 46 | for(int i = 0; i < list.size(); i++) 47 | { 48 | rowData[0] = list.get(i).getId(); 49 | rowData[1] = list.get(i).getDesc(); 50 | rowData[2] = list.get(i).getPvp(); 51 | rowData[3] = list.get(i).getPrice(); 52 | rowData[4] = list.get(i).getStock(); 53 | rowData[5] = list.get(i).getCategory(); 54 | rowData[6] = list.get(i).getDateIn(); 55 | rowData[7] = list.get(i).getCodeProv(); 56 | model.addRow(rowData); 57 | } 58 | 59 | } 60 | 61 | /** 62 | * This method is called from within the constructor to initialize the form. 63 | * WARNING: Do NOT modify this code. The content of this method is always 64 | * regenerated by the Form Editor. 65 | */ 66 | @SuppressWarnings("unchecked") 67 | // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents 68 | private void initComponents() { 69 | 70 | jLabel1 = new javax.swing.JLabel(); 71 | jScrollPane2 = new javax.swing.JScrollPane(); 72 | jTable1 = new javax.swing.JTable(); 73 | 74 | setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); 75 | 76 | jLabel1.setFont(new java.awt.Font("Century Gothic", 1, 24)); // NOI18N 77 | jLabel1.setText("PRODUCTOS"); 78 | 79 | jTable1.setModel(new javax.swing.table.DefaultTableModel( 80 | new Object [][] { 81 | 82 | }, 83 | new String [] { 84 | "ID", "NOMBRE", "PVP", "PRECIO", "STOCK", "CATEGORIA", "FECHA IN", "PROVEEDOR" 85 | } 86 | ) { 87 | boolean[] canEdit = new boolean [] { 88 | false, false, false, false, false, false, false, false 89 | }; 90 | 91 | public boolean isCellEditable(int rowIndex, int columnIndex) { 92 | return canEdit [columnIndex]; 93 | } 94 | }); 95 | jScrollPane2.setViewportView(jTable1); 96 | 97 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); 98 | getContentPane().setLayout(layout); 99 | layout.setHorizontalGroup( 100 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 101 | .addGroup(layout.createSequentialGroup() 102 | .addGap(228, 228, 228) 103 | .addComponent(jLabel1) 104 | .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) 105 | .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() 106 | .addContainerGap(22, Short.MAX_VALUE) 107 | .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 566, javax.swing.GroupLayout.PREFERRED_SIZE) 108 | .addGap(21, 21, 21)) 109 | ); 110 | layout.setVerticalGroup( 111 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 112 | .addGroup(layout.createSequentialGroup() 113 | .addGap(20, 20, 20) 114 | .addComponent(jLabel1) 115 | .addGap(18, 18, 18) 116 | .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 330, javax.swing.GroupLayout.PREFERRED_SIZE) 117 | .addContainerGap(27, Short.MAX_VALUE)) 118 | ); 119 | 120 | pack(); 121 | }// </editor-fold>//GEN-END:initComponents 122 | 123 | // Variables declaration - do not modify//GEN-BEGIN:variables 124 | private javax.swing.JLabel jLabel1; 125 | private javax.swing.JScrollPane jScrollPane2; 126 | private javax.swing.JTable jTable1; 127 | // End of variables declaration//GEN-END:variables 128 | } 129 | -------------------------------------------------------------------------------- /java/progressbar-hilos/main.form: -------------------------------------------------------------------------------- 1 | <?xml version="1.0" encoding="UTF-8" ?> 2 | 3 | <Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JFrameFormInfo"> 4 | <Properties> 5 | <Property name="defaultCloseOperation" type="int" value="3"/> 6 | </Properties> 7 | <SyntheticProperties> 8 | <SyntheticProperty name="formSizePolicy" type="int" value="1"/> 9 | <SyntheticProperty name="generateCenter" type="boolean" value="false"/> 10 | </SyntheticProperties> 11 | <AuxValues> 12 | <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> 13 | <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> 14 | <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> 15 | <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> 16 | <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> 17 | <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> 18 | <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> 19 | <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> 20 | <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> 21 | </AuxValues> 22 | 23 | <Layout> 24 | <DimensionLayout dim="0"> 25 | <Group type="103" groupAlignment="0" attributes="0"> 26 | <Group type="102" attributes="0"> 27 | <Group type="103" groupAlignment="0" attributes="0"> 28 | <Group type="102" alignment="0" attributes="0"> 29 | <EmptySpace min="-2" pref="65" max="-2" attributes="0"/> 30 | <Group type="103" groupAlignment="0" max="-2" attributes="0"> 31 | <Component id="jButton3" max="32767" attributes="0"/> 32 | <Component id="jButton2" max="32767" attributes="0"/> 33 | <Component id="jButton1" max="32767" attributes="0"/> 34 | <Component id="pbar" pref="214" max="32767" attributes="0"/> 35 | </Group> 36 | </Group> 37 | <Group type="102" alignment="0" attributes="0"> 38 | <EmptySpace min="-2" pref="127" max="-2" attributes="0"/> 39 | <Component id="jButton4" min="-2" max="-2" attributes="0"/> 40 | </Group> 41 | <Group type="102" alignment="0" attributes="0"> 42 | <EmptySpace min="-2" pref="159" max="-2" attributes="0"/> 43 | <Component id="plabel" min="-2" max="-2" attributes="0"/> 44 | </Group> 45 | </Group> 46 | <EmptySpace pref="69" max="32767" attributes="0"/> 47 | </Group> 48 | </Group> 49 | </DimensionLayout> 50 | <DimensionLayout dim="1"> 51 | <Group type="103" groupAlignment="0" attributes="0"> 52 | <Group type="102" alignment="0" attributes="0"> 53 | <EmptySpace min="-2" pref="57" max="-2" attributes="0"/> 54 | <Component id="jButton1" min="-2" pref="43" max="-2" attributes="0"/> 55 | <EmptySpace type="separate" max="-2" attributes="0"/> 56 | <Component id="jButton2" min="-2" pref="42" max="-2" attributes="0"/> 57 | <EmptySpace type="separate" max="-2" attributes="0"/> 58 | <Component id="jButton3" min="-2" pref="43" max="-2" attributes="0"/> 59 | <EmptySpace type="unrelated" max="-2" attributes="0"/> 60 | <Component id="plabel" min="-2" max="-2" attributes="0"/> 61 | <EmptySpace min="-2" pref="7" max="-2" attributes="0"/> 62 | <Component id="pbar" min="-2" pref="24" max="-2" attributes="0"/> 63 | <EmptySpace type="unrelated" max="-2" attributes="0"/> 64 | <Component id="jButton4" min="-2" max="-2" attributes="0"/> 65 | <EmptySpace pref="41" max="32767" attributes="0"/> 66 | </Group> 67 | </Group> 68 | </DimensionLayout> 69 | </Layout> 70 | <SubComponents> 71 | <Component class="javax.swing.JButton" name="jButton1"> 72 | <Properties> 73 | <Property name="text" type="java.lang.String" value="Proceso sin hilos"/> 74 | </Properties> 75 | <Events> 76 | <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton1ActionPerformed"/> 77 | </Events> 78 | </Component> 79 | <Component class="javax.swing.JButton" name="jButton2"> 80 | <Properties> 81 | <Property name="text" type="java.lang.String" value="Proceso con hilos"/> 82 | </Properties> 83 | <Events> 84 | <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton2ActionPerformed"/> 85 | </Events> 86 | </Component> 87 | <Component class="javax.swing.JButton" name="jButton3"> 88 | <Properties> 89 | <Property name="text" type="java.lang.String" value="Mensaje"/> 90 | </Properties> 91 | <Events> 92 | <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton3ActionPerformed"/> 93 | </Events> 94 | </Component> 95 | <Component class="javax.swing.JProgressBar" name="pbar"> 96 | </Component> 97 | <Component class="javax.swing.JButton" name="jButton4"> 98 | <Properties> 99 | <Property name="text" type="java.lang.String" value="reset bar"/> 100 | </Properties> 101 | <Events> 102 | <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton4ActionPerformed"/> 103 | </Events> 104 | </Component> 105 | <Component class="javax.swing.JLabel" name="plabel"> 106 | <Properties> 107 | <Property name="text" type="java.lang.String" value="0%"/> 108 | </Properties> 109 | </Component> 110 | </SubComponents> 111 | </Form> 112 | -------------------------------------------------------------------------------- /java/progressbar-hilos/main.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package com.mycompany.progressbar; 7 | import java.awt.event.ActionEvent; 8 | import java.awt.event.ActionListener; 9 | import javax.swing.Timer; 10 | import javax.swing.JOptionPane; 11 | 12 | /** 13 | * 14 | * @author Tomvargas 15 | */ 16 | 17 | public class main extends javax.swing.JFrame { 18 | 19 | 20 | /** 21 | * Creates new form main 22 | */ 23 | public int n=0; 24 | public Timer t; 25 | 26 | public main() { 27 | initComponents(); 28 | } 29 | 30 | /** 31 | * This method is called from within the constructor to initialize the form. 32 | * WARNING: Do NOT modify this code. The content of this method is always 33 | * regenerated by the Form Editor. 34 | */ 35 | @SuppressWarnings("unchecked") 36 | // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents 37 | private void initComponents() { 38 | 39 | jButton1 = new javax.swing.JButton(); 40 | jButton2 = new javax.swing.JButton(); 41 | jButton3 = new javax.swing.JButton(); 42 | pbar = new javax.swing.JProgressBar(); 43 | jButton4 = new javax.swing.JButton(); 44 | plabel = new javax.swing.JLabel(); 45 | 46 | setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); 47 | 48 | jButton1.setText("Proceso sin hilos"); 49 | jButton1.addActionListener(new java.awt.event.ActionListener() { 50 | public void actionPerformed(java.awt.event.ActionEvent evt) { 51 | jButton1ActionPerformed(evt); 52 | } 53 | }); 54 | 55 | jButton2.setText("Proceso con hilos"); 56 | jButton2.addActionListener(new java.awt.event.ActionListener() { 57 | public void actionPerformed(java.awt.event.ActionEvent evt) { 58 | jButton2ActionPerformed(evt); 59 | } 60 | }); 61 | 62 | jButton3.setText("Mensaje"); 63 | jButton3.addActionListener(new java.awt.event.ActionListener() { 64 | public void actionPerformed(java.awt.event.ActionEvent evt) { 65 | jButton3ActionPerformed(evt); 66 | } 67 | }); 68 | 69 | jButton4.setText("reset bar"); 70 | jButton4.addActionListener(new java.awt.event.ActionListener() { 71 | public void actionPerformed(java.awt.event.ActionEvent evt) { 72 | jButton4ActionPerformed(evt); 73 | } 74 | }); 75 | 76 | plabel.setText("0%"); 77 | 78 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); 79 | getContentPane().setLayout(layout); 80 | layout.setHorizontalGroup( 81 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 82 | .addGroup(layout.createSequentialGroup() 83 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 84 | .addGroup(layout.createSequentialGroup() 85 | .addGap(65, 65, 65) 86 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) 87 | .addComponent(jButton3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 88 | .addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 89 | .addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 90 | .addComponent(pbar, javax.swing.GroupLayout.DEFAULT_SIZE, 214, Short.MAX_VALUE))) 91 | .addGroup(layout.createSequentialGroup() 92 | .addGap(127, 127, 127) 93 | .addComponent(jButton4)) 94 | .addGroup(layout.createSequentialGroup() 95 | .addGap(159, 159, 159) 96 | .addComponent(plabel))) 97 | .addContainerGap(69, Short.MAX_VALUE)) 98 | ); 99 | layout.setVerticalGroup( 100 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 101 | .addGroup(layout.createSequentialGroup() 102 | .addGap(57, 57, 57) 103 | .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE) 104 | .addGap(18, 18, 18) 105 | .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE) 106 | .addGap(18, 18, 18) 107 | .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE) 108 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) 109 | .addComponent(plabel) 110 | .addGap(7, 7, 7) 111 | .addComponent(pbar, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE) 112 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) 113 | .addComponent(jButton4) 114 | .addContainerGap(41, Short.MAX_VALUE)) 115 | ); 116 | 117 | pack(); 118 | }// </editor-fold>//GEN-END:initComponents 119 | 120 | private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed 121 | // TODO add your handling code here: 122 | ActionListener accion=new ActionListener() { 123 | 124 | public void actionPerformed(ActionEvent e) { 125 | if(n<=100){ 126 | pbar.setValue(n); 127 | plabel.setText(String.valueOf(pbar.getValue())+"%"); 128 | n=n+10; 129 | }else{ 130 | t.stop(); 131 | 132 | t=null; 133 | n=0; 134 | 135 | } 136 | } 137 | }; 138 | t=new Timer(500, accion); 139 | t.start(); 140 | }//GEN-LAST:event_jButton2ActionPerformed 141 | 142 | private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed 143 | // TODO add your handling code here: 144 | JOptionPane.showMessageDialog(null, "Programa desarrollado por Tomas Vargas"); 145 | }//GEN-LAST:event_jButton3ActionPerformed 146 | 147 | private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed 148 | // TODO add your handling code here: 149 | int i; 150 | 151 | try { 152 | for (i=10;i<=100;i+=10) { 153 | pbar.setValue(i); 154 | plabel.setText(String.valueOf(pbar.getValue())+"%"); 155 | Thread.sleep(500); 156 | } 157 | } 158 | catch (Exception e) { 159 | } 160 | 161 | }//GEN-LAST:event_jButton1ActionPerformed 162 | 163 | private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed 164 | // TODO add your handling code here: 165 | pbar.setValue(0); 166 | plabel.setText("0%"); 167 | }//GEN-LAST:event_jButton4ActionPerformed 168 | 169 | /** 170 | * @param args the command line arguments 171 | */ 172 | public static void main(String args[]) { 173 | /* Set the Nimbus look and feel */ 174 | //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> 175 | /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. 176 | * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 177 | */ 178 | try { 179 | for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { 180 | if ("Nimbus".equals(info.getName())) { 181 | javax.swing.UIManager.setLookAndFeel(info.getClassName()); 182 | break; 183 | } 184 | } 185 | } catch (ClassNotFoundException ex) { 186 | java.util.logging.Logger.getLogger(main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 187 | } catch (InstantiationException ex) { 188 | java.util.logging.Logger.getLogger(main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 189 | } catch (IllegalAccessException ex) { 190 | java.util.logging.Logger.getLogger(main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 191 | } catch (javax.swing.UnsupportedLookAndFeelException ex) { 192 | java.util.logging.Logger.getLogger(main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 193 | } 194 | //</editor-fold> 195 | 196 | /* Create and display the form */ 197 | java.awt.EventQueue.invokeLater(new Runnable() { 198 | public void run() { 199 | new main().setVisible(true); 200 | } 201 | }); 202 | } 203 | 204 | // Variables declaration - do not modify//GEN-BEGIN:variables 205 | private javax.swing.JButton jButton1; 206 | private javax.swing.JButton jButton2; 207 | private javax.swing.JButton jButton3; 208 | private javax.swing.JButton jButton4; 209 | private javax.swing.JProgressBar pbar; 210 | private javax.swing.JLabel plabel; 211 | // End of variables declaration//GEN-END:variables 212 | } 213 | -------------------------------------------------------------------------------- /java/restaurante/.classpath: -------------------------------------------------------------------------------- 1 | <?xml version="1.0" encoding="UTF-8"?> 2 | <classpath> 3 | <classpathentry kind="src" output="target/classes" path="src/main/java"> 4 | <attributes> 5 | <attribute name="optional" value="true"/> 6 | <attribute name="maven.pomderived" value="true"/> 7 | </attributes> 8 | </classpathentry> 9 | <classpathentry kind="src" output="target/test-classes" path="src/test/java"> 10 | <attributes> 11 | <attribute name="optional" value="true"/> 12 | <attribute name="maven.pomderived" value="true"/> 13 | <attribute name="test" value="true"/> 14 | </attributes> 15 | </classpathentry> 16 | <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-15"> 17 | <attributes> 18 | <attribute name="maven.pomderived" value="true"/> 19 | </attributes> 20 | </classpathentry> 21 | <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> 22 | <attributes> 23 | <attribute name="maven.pomderived" value="true"/> 24 | </attributes> 25 | </classpathentry> 26 | <classpathentry kind="src" path="target/generated-sources/annotations"> 27 | <attributes> 28 | <attribute name="optional" value="true"/> 29 | <attribute name="maven.pomderived" value="true"/> 30 | <attribute name="ignore_optional_problems" value="true"/> 31 | <attribute name="m2e-apt" value="true"/> 32 | </attributes> 33 | </classpathentry> 34 | <classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations"> 35 | <attributes> 36 | <attribute name="optional" value="true"/> 37 | <attribute name="maven.pomderived" value="true"/> 38 | <attribute name="ignore_optional_problems" value="true"/> 39 | <attribute name="m2e-apt" value="true"/> 40 | <attribute name="test" value="true"/> 41 | </attributes> 42 | </classpathentry> 43 | <classpathentry kind="output" path="target/classes"/> 44 | </classpath> 45 | -------------------------------------------------------------------------------- /java/restaurante/.project: -------------------------------------------------------------------------------- 1 | <?xml version="1.0" encoding="UTF-8"?> 2 | <projectDescription> 3 | <name>restaurante</name> 4 | <comment></comment> 5 | <projects> 6 | </projects> 7 | <buildSpec> 8 | <buildCommand> 9 | <name>org.eclipse.jdt.core.javabuilder</name> 10 | <arguments> 11 | </arguments> 12 | </buildCommand> 13 | <buildCommand> 14 | <name>org.eclipse.m2e.core.maven2Builder</name> 15 | <arguments> 16 | </arguments> 17 | </buildCommand> 18 | </buildSpec> 19 | <natures> 20 | <nature>org.eclipse.jdt.core.javanature</nature> 21 | <nature>org.eclipse.m2e.core.maven2Nature</nature> 22 | </natures> 23 | <filteredResources> 24 | <filter> 25 | <id>1623418101703</id> 26 | <name></name> 27 | <type>30</type> 28 | <matcher> 29 | <id>org.eclipse.core.resources.regexFilterMatcher</id> 30 | <arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments> 31 | </matcher> 32 | </filter> 33 | </filteredResources> 34 | </projectDescription> 35 | -------------------------------------------------------------------------------- /java/restaurante/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//src/main/java=UTF-8 3 | encoding//src/test/java=UTF-8 4 | encoding/<project>=UTF-8 5 | -------------------------------------------------------------------------------- /java/restaurante/.settings/org.eclipse.jdt.apt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.apt.aptEnabled=false 3 | -------------------------------------------------------------------------------- /java/restaurante/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=15 3 | org.eclipse.jdt.core.compiler.compliance=15 4 | org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled 5 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 6 | org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore 7 | org.eclipse.jdt.core.compiler.processAnnotations=disabled 8 | org.eclipse.jdt.core.compiler.release=disabled 9 | org.eclipse.jdt.core.compiler.source=15 10 | -------------------------------------------------------------------------------- /java/restaurante/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /java/restaurante/pom.xml: -------------------------------------------------------------------------------- 1 | <?xml version="1.0" encoding="UTF-8"?> 2 | <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 3 | <modelVersion>4.0.0</modelVersion> 4 | <groupId>com.mycompany</groupId> 5 | <artifactId>restaurante</artifactId> 6 | <version>1.0-SNAPSHOT</version> 7 | <packaging>jar</packaging> 8 | <properties> 9 | <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 10 | <maven.compiler.source>15</maven.compiler.source> 11 | <maven.compiler.target>15</maven.compiler.target> 12 | </properties> 13 | </project> -------------------------------------------------------------------------------- /java/restaurante/src/main/java/com/mycompany/restaurante/main.java: -------------------------------------------------------------------------------- 1 | package com.mycompany.restaurante; 2 | 3 | /** 4 | * @author tomvargas 5 | */ 6 | import com.mycompany.restaurante.users.client; //import client class for instance a object 7 | import javax.swing.JOptionPane; 8 | 9 | public class main 10 | { 11 | public static void main(String[] args){ 12 | client a = new client("Juan", "Vegetales", true, 500, 0);//------------- instamce a object from clients 13 | double datos = a.descuentocliente();//---------------------------------- call client method 14 | String nombre = a.getNombre();//---------------------------------------- get client name 15 | String pedido = a.getPedido();//---------------------------------------- get client order 16 | 17 | //show client data 18 | JOptionPane.showMessageDialog(null,"Nombre: "+nombre+"\n"+"Pedido: "+pedido+"\n"+"Pago: "+datos); 19 | } 20 | } 21 | 22 | -------------------------------------------------------------------------------- /java/restaurante/src/main/java/com/mycompany/restaurante/users/client.java: -------------------------------------------------------------------------------- 1 | package com.mycompany.restaurante.users; 2 | 3 | /** 4 | * @author tomvargas 5 | */ 6 | public class client 7 | { 8 | private String nombre; 9 | private String pedido; 10 | private boolean pagoEfectivo; 11 | private int precio; 12 | private double pago; 13 | 14 | //declare constructor of class 15 | public client (String nombre, String pedido, boolean pagoEfectivo, int precio, double pago){ 16 | this.nombre=nombre; 17 | this.pedido=pedido; 18 | this.pagoEfectivo=pagoEfectivo; 19 | this.precio=precio; 20 | this.pago=pago; 21 | } 22 | 23 | 24 | public double descuentocliente(){ 25 | double desc=0; 26 | if (pagoEfectivo){//---------------------------------------------------- if true or false 27 | desc=precio-precio*0.10; 28 | pago = precio-desc; 29 | 30 | return desc; 31 | } 32 | else{ 33 | return 0; 34 | } 35 | } 36 | 37 | public String getNombre(){ 38 | return nombre; 39 | } 40 | 41 | public String getPedido(){ 42 | return pedido; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /javascript/README.md: -------------------------------------------------------------------------------- 1 | # EJERCICIOS DE Javascript 2 | En esta carpeta puedes encontrar varios ejercicios de *Javascript*, si necesitas aprender algo en específico de este lenguaje te invito a dejarme un comentario en [este foro de discusión](https://github.com/Tomvargas/Programas/discussions/3). 3 | 4 | * ### Strings.js 5 | recopila un ejemplo práctico de varios métodos para las cadenas de texto 6 | -------------------------------------------------------------------------------- /javascript/strings.js: -------------------------------------------------------------------------------- 1 | /* 2 | Este ejercicio comprende los métodos más utilizados en el estanddard actual 3 | Te invito a ver mis apuntes donde encontrarás la teoría de todos los temas de Js 4 | 🌎 https://tomvargasd.notion.site/JAVASCRIPT-NOTES-4dbf0da11f364f5f96f8e672e46cd6ca 5 | Omitan el ingles mal escrito, estoy aprendiendo 😅 6 | */ 7 | //declaramos una variable const la cual no puede ser modificada y sirve a nivel global 8 | const author = "tomvargas"; 9 | 10 | //declaramos variables de tipo let (se ejecuta solamente en un bloque 11 | // a diferencia de var o const que sirven a nivel global). 12 | let str1 = "Hola mundo"; 13 | let str2 ="Hello world"; 14 | 15 | 16 | //--------------------------------------------------- concatenar cadenas de texto 17 | function contatenar(str1, str2){ // recive dos variables string 18 | 19 | // almacena en la variable newstr el string str1 unido a la cadena ' - es | ' 20 | // todo esto se une a la variable str2 unido a la cadena ' - en' 21 | let newstr = str1.concat(' - es | '.concat(str2.concat(' - en'))); 22 | 23 | return newstr;// devuelve el valor de newstr 24 | } 25 | 26 | // el resultado final será "Hola mundo - es | Hello world - en" 27 | console.log(contatenar(str1, str2)); 28 | //------------------------------------------------------------------------------- 29 | 30 | //------------------------------------------ validar cadenas al inicio o al final 31 | function validar(str1, str2){ 32 | 33 | // si str1 comienza con hola y str2 comienza con hello 34 | if(str1.startsWith('Hola') && str2.startsWith('Hello')){ 35 | return "Ambas cadenas comienzan con Hola"; 36 | 37 | // si str1 termina con mundo y str2 termina con world 38 | }else if(str1.endsWidth('mundo') && str2.endsWidth('world')){ 39 | return "Ambas cadenas terminan con mundo"; 40 | } 41 | 42 | // en el caso que ninguna condición se cumpla, retorna esta cadena 43 | return "Ninguna cadena empieza con Hola ni termina con mundo"; 44 | } 45 | 46 | // el resultado al tener las variables "Hola mundo" y "Hello world" será: 47 | // Ambas cadenas comienzan con Hola 48 | console.log(validar(str1, str2)); 49 | //------------------------------------------------------------------------------- 50 | 51 | // --------------------------------------------------------- buscar en una cadena 52 | function buscar(str1, str2){ 53 | 54 | // mensaje por defecto 55 | let msj = "No hay resultados"; 56 | 57 | //si str1 incluye la cadena "mundo" y str2 la cadena "world" 58 | if(str1.includes("mundo") && str2.includes("world")){ 59 | // el mensaje se modifica 60 | msj = "Se encontró la cadena mundo y world en las variables srt1 y str2 respectivamente."; 61 | } 62 | 63 | // regresa el mensaje 64 | return msj; 65 | } 66 | 67 | // el resultado es: 68 | // Se encontró la cadena mundo y world en las variables srt1 y str2 respectivamente. 69 | console.log(buscar(str1, str2)); 70 | //------------------------------------------------------------------------------- 71 | 72 | // --------------------------------------------------------- buscar en una cadena 73 | function encontrar(str1, str2){ 74 | 75 | // mensaje por defecto 76 | let msj = `No hay resultados`; 77 | 78 | //indexOf devuelve la posición de la primera ocurrencia de la cadena buscada, devuelve -1 si no se encuentra 79 | let result = str1.indexOf(str2); 80 | 81 | //si result es diferente de -1 entonces encntró la cadena mundo en str1 82 | if(result != -1){ 83 | // el mensaje se modifica 84 | msj = `Se encontró la cadena mundo en la variable srt1, posición: ${result}`; 85 | } 86 | 87 | // regresa el mensaje 88 | return msj; 89 | } 90 | 91 | // el resultado es: 92 | // Se encontró la cadena mundo y world en las variables srt1 y str2 respectivamente. 93 | console.log(encontrar(str1, "mundo")); 94 | //------------------------------------------------------------------------------- 95 | 96 | // --------------------------------------------------------- proximamente más ... -------------------------------------------------------------------------------- /python/README.md: -------------------------------------------------------------------------------- 1 | # EJERCICIOS DE PYTHON 2 | Aquí puedes encontrar ejercicios hechos en *python*, si necesitas aprender algo en específico de este lenguaje te invito a dejarme un comentario en [este foro de discusión](https://github.com/Tomvargas/Programas/discussions/3). 3 | Te dejo una lista con la descripción de cada uno de los ejercicios en este nivel: 4 | * ### Calcular derivadas simples 5 | Ingresa una función simple de la forma indicada en el programa para sacar su derivada. 6 | * ### Calcular pago de empleados 7 | Calcula el sueldo a pagar de un empleado en base a su horario laboral y horas extra. 8 | * ### Calcular ventas de sucursales 9 | Indica en cuantas ciudades hay sucursales, en cada ciudad cuantas sucursales, en cada sucursal cuantos empleados y la ganancia generada por cada empleado. 10 | * ### Conversión base de numeros 11 | Convierte numeros en binario, octal, hexadecimal, decimal. 12 | * ### Diagnosticar leucemia aguda 13 | Algoritmo para diagnosticar si un paciente tiene leucemia aguda. 14 | * ### Imprimir factura 15 | Genera una factura con datos y calcula el total a pagar imprimiendo los datos en consola. 16 | * ### Numeros primos 17 | Determina si un numero ingresado es primo o no. 18 | * ### Mostrar hora y fecha 19 | Imprime la hora y la fecha actual de tu sistema. 20 | * ### Registro de estudiantes 21 | Agrega, muestra o elimina estudiantes. 22 | * ### Sistema de biblioteca 23 | Gestiona inventario de libros. 24 | -------------------------------------------------------------------------------- /python/calcular-derivadas-simples.py: -------------------------------------------------------------------------------- 1 | #LEER EL PRIMER PRINT, SON LAS INTRUCCIONES PARA QUE EL USUARIO PUEDA INGRESAR LA FUNCIÓN EN EL FORMATO CORRECTO 2 | #@author Tomas Vargas 3 | 4 | import diff from sympy 5 | 6 | print('## operadores ##\n1) Exponente **\n2) Multiplicacion *\n3) Suma +\n4) Resta -\n## Recomendaciones ##\n- para una expresion utilizar la forma base a*X**b+X-c') 7 | 8 | # py -m pip install sympy 9 | import diff from sympy 10 | 11 | n=input('ingrese el numero de derivadas que desea operar: ') 12 | 13 | f=input('Ingrese una función f(x): ') 14 | 15 | print('Derivada: ', diff(f,'x',n)) 16 | 17 | #Llama la función diff de la librería sympy que calcula automáticamente la función dada 18 | -------------------------------------------------------------------------------- /python/calcular-pago-empleados.py: -------------------------------------------------------------------------------- 1 | import io #importar la librería para trabajar con ficheros 2 | import os #Módulo os para acceder funcionalidades del sistema operativo 3 | 4 | #--------------------------------------------------------------------------- esta función guarda los datos linea por linea 5 | def save(data): 6 | f = open("Vendedores.bin", "a") 7 | for i in data: 8 | f.write(i) 9 | f.write("\n") 10 | f.close() 11 | 12 | #---------------------------------------------------------------------------lee los datos del fichero 13 | def read(): 14 | lista=[] 15 | f = open("Vendedores.bin", "r") # abre el archivo 16 | for lines in f.readlines(): #sentencia para recorrer las lineas del archivo 17 | lista.append(lines.rstrip('\n')) # agrega al final de una lista el valor de la linea del fichero sin el salto de linea con la funcion rstrip 18 | f.close() # cerrar el archivo 19 | 20 | #regresa la lista de valores obtenidos del fichero 21 | return lista 22 | 23 | #-------------------------------------------------------------------------- valida que el dato contenga solamente digitos 24 | def onlyn(var): 25 | return var.isdigit() 26 | 27 | #-------------------------------------------------------------------------- registra los vendedores y los guarda en el fichero 28 | def R_vend(): 29 | v=1 30 | data=[] 31 | 32 | while(v==1): 33 | os.system("cls") 34 | 35 | while(v==1): 36 | cod=input("Codigo de vendedor: ") 37 | if onlyn(cod)==True: 38 | data.append(cod) 39 | v=0 40 | else: 41 | print("El codigo solo debe contener numeros.\n") 42 | 43 | data.append(input("Nombre del vendedor: ")) 44 | 45 | v=1 46 | while(v==1): 47 | lvl=input("Nivel de vendedor (1 - 2 - 3): ") 48 | if onlyn(lvl)==True: 49 | if int(lvl) > 0 and int(lvl) < 4: 50 | data.append(lvl) 51 | v=0 52 | else: 53 | print("El nivel del vendedor solo puede ser entre 1 y 3.") 54 | else: 55 | print("El nivel debe ser un dato numerico (1 - 2 - 3).\n") 56 | 57 | v=1 58 | while(v==1): 59 | try: 60 | data.append(str(float(input("Monto vendido: ")))) 61 | v=0 62 | except: 63 | print("Entrada incorrecta...") 64 | 65 | v=1 66 | while(v==1): 67 | op=input("Desea ingresar otro vendedor? (1=si | 0=no): ") 68 | if onlyn(op)==True: 69 | v=0 70 | else: 71 | print("Opcion Erronea.\n") 72 | 73 | save(data) #guarda el vendedor 74 | 75 | v=1 76 | if op == "0": 77 | v=0 78 | 79 | #------------------------------------------------------------------------------ devuelve el sueldo segun un parámetro recivido 80 | def sueldo(s): 81 | if s == 1: 82 | S=400.0 83 | elif s == 2: 84 | S=500.0 85 | elif s==3: 86 | S=600.0 87 | else: 88 | S=0 89 | return S 90 | 91 | #------------------------------------------------------------------------------- devuelve un valor booleano false o true si el empleado merece un bono 92 | def bono(valu): 93 | data=read() 94 | mon=[] 95 | for i in range(3,len(data),4): 96 | mon.append(float(data[i])) 97 | nmax=max(mon) 98 | if valu == nmax: 99 | return True 100 | else: 101 | return False 102 | 103 | #------------------------------------------------------------------------------ Lee los registros y calcula el pago corespondiente a cada vendedor 104 | def pago(): 105 | data=read() 106 | pagos=[] 107 | for i in range(0,len(data),4): 108 | print("\n") 109 | print("===============================") 110 | print("Codigo: ", data[i]) 111 | print("Nombre: ", data[i+1]) 112 | print("Nivel: ", data[i+2]) 113 | print("Monto vendido: ", data[i+3]) 114 | s=sueldo(int(data[i+2])) 115 | ad=(float(data[i+3])*5)/100 116 | if bono(float(data[i+3]))==True: 117 | s+=100 118 | pag=s+ad 119 | print("Por pagar: ", pag) 120 | pagos.append(pag) 121 | print("===============================") 122 | print("\n") 123 | 124 | tot=0 125 | for i in pagos: 126 | tot+=i 127 | 128 | print("Total por pagar: $", tot) 129 | print("===============================") 130 | 131 | #------------------------------------------------------------------------------------ bloque de código principal 132 | v=1 133 | while(v==1): 134 | os.system("cls") 135 | print("\t### EMPRESA ANONIMUS ###") 136 | print("1) Registrar vendedores.\n2) Monto de pago.\n3) Salir.") 137 | v=1 138 | while(v==1): 139 | try: 140 | op=int(input("Ingrese una opcion: ")) 141 | v=0 142 | except: 143 | print("Entrada invalida.") 144 | 145 | v=1 146 | if op==1: 147 | R_vend() 148 | elif op==2: 149 | pago() 150 | input() 151 | elif op==3: 152 | v=0 153 | input("bye...") 154 | else: 155 | input("Opcion incorrecta, intente de nuevo.") 156 | -------------------------------------------------------------------------------- /python/calcular-ventas-de-sucursales.py: -------------------------------------------------------------------------------- 1 | #Software para el area cientifica 2 | #@author Tomas Vargas 3 | 4 | ciudades = int(input("-> En cuantas ciudades hay sucursales?: ")) 5 | venta_total = 0 6 | for i in range(0, ciudades): 7 | print("\t-<<<CIUDAD ", i+1, ">>>-") 8 | t = int(input("-> cuantas tiendas hay en esta ciudad?: ")) 9 | venta_ciudad = 0 10 | 11 | for j in range(0, t): 12 | print("\n", "\t-<<TIENDA ", j+1, ">>-") 13 | n = int(input("-> cuantos empleados hay en la tienda?: ")) 14 | venta_local = 0 15 | 16 | for k in range(0, n): 17 | print("\n", "\t-<EMPLEADO ", k+1, ">-") 18 | venta = int(input("-> ingrese el monto de ventas realizadas: ")) 19 | venta_local += venta 20 | 21 | print("\n", "\t-> ventas realizadas en la tienda ", 22 | j+1, ": $", "{0:.2f}".format(venta_local)) 23 | 24 | venta_ciudad += venta_local 25 | 26 | print("\n", "\t\t-> ventas realizadas en la ciudad ", 27 | i+1, ": $", "{0:.2f}".format(venta_ciudad)) 28 | 29 | venta_total += venta_ciudad 30 | 31 | print("\n", "\t-> ventas totales: $", "{0:.2f}".format(venta_total), "\n") 32 | input() 33 | -------------------------------------------------------------------------------- /python/conversion-base-de-numeros.py: -------------------------------------------------------------------------------- 1 | #Software para el area cientifica 2 | #@author Tomas Vargas 3 | 4 | print("## CONVERSION DE NUMEROS ##","\n") 5 | print("1) CONVERSION DE NUMERO EN BASE 10 A DISTINTAS BASES (2, 8, 16)") 6 | print("2) CONVERSION DE NUMEROS EN BASES DISTINTAS A NUMERO EN BASE 10") 7 | op=int(input("-> INGRESE UNA OPCION: ")) 8 | 9 | if op==1: 10 | num=int(input("INGRESE EL NUMERO EN BASE DIEZ: ")) 11 | bas=int(input("INGRESE LA BASE A LA CUAL SE VA A CONVERTIR: ")) 12 | c=[] 13 | if bas==16: 14 | val="" 15 | while num!=0: 16 | x='0123456789ABCDEF' 17 | c=num%bas 18 | c1=x[c] 19 | val=str(c1)+val 20 | num=int(num//bas) 21 | print(val) 22 | elif bas==2 or bas==8: 23 | while num>0: 24 | c.insert(0, num%bas) 25 | num=num//bas 26 | val=''.join(str(i) for i in c) 27 | print(val) 28 | else: 29 | input("SOLO SE PUEDE INGRESAR BASES DE 2, 8 O 16...") 30 | 31 | elif op==2: 32 | bas=int(input("INDIQUE LA BASE DEL NUMERO QUE SE VA A INGRESAR: ")) 33 | if bas==2: 34 | num=input("INGRESE EL NUMERO: ") 35 | val=int(str(num),2) 36 | print(val) 37 | elif bas==8: 38 | num=input("INGRESE EL NUMERO: ") 39 | val="" 40 | while num!=0: 41 | x='0123456789ABCDEF' 42 | c=num%bas 43 | c1=x[c] 44 | val=str(c1)+val 45 | num=int(num//bas) 46 | print(val) 47 | elif bas==16: 48 | num=input("INGRESE EL NUMERO: ") 49 | val=int(num, 16) 50 | print(val) 51 | else: 52 | input("!! LA BASE QUE INGRESO NO ESTA DISPONIBLE !!...") 53 | else: 54 | input("!! LA OPCION QUE INGRESO ES INCORRECTA !!...") 55 | 56 | input() 57 | -------------------------------------------------------------------------------- /python/diagnosticar-leucemia-aguda.py: -------------------------------------------------------------------------------- 1 | #Software para el area cientifica 2 | #@author Tomas Vargas 3 | 4 | def especialista(): 5 | print('Indique si está indicado realizar AMO') 6 | op = input('\t1) si\n\t2) no\n> ingrese una opcion: ') 7 | if int(op) == 1: 8 | bl = input('¿Existe precencia de blastos? (y/n)') 9 | if bl.lower() == 'y': 10 | print('Su paciente tiene leucemia aguda.') 11 | elif bl.lower() == 'n': 12 | print('Su paciente no padece de leucemia aguda.\nPorfavor investigar si puede ser: \n - Anemia aplastica\n - Neoplasia\n - Infeciones\n - Hemofagositosis\n - Enfermedad por atesoramiento\n - Drogas\n>> Gracias por realizar su consulta de diagnostico.') 13 | 14 | elif int(op) == 2: 15 | print('Su paciente no padece de leucemia aguda.\nPorfavor investigar si puede ser:\n- infeccion\n- Anemias hemoliticas\n- Altercion inmunologica\n- Neoplasias\n>> Gracias por realizar su consulta de diagnostico.') 16 | else: 17 | print('Debe ingresar una opción establecida.') 18 | 19 | 20 | print('** DIAGNOSTICO TEMPRANO U OPORTUNO DE LEUCEMIA AGUDA **') 21 | print('Seleccione las opciones que se ajusten a la situcion de su paciente.') 22 | print('====================================================================') 23 | print('\nSintoma principal:') 24 | print('\n\t1) Palidez\n\t2) Fiebre\n\t3) Dolor oseo\n\t4) Dolor general\n\t5) Ninguna') 25 | op = input('> Ingrese una opcion: ') 26 | if int(op)==5: 27 | print('\tSu paciente Solo padece ese sintoma o debe diagnosticarlo de otra posible enfermedad.') 28 | elif int(op)<1 or int(op)>5: 29 | print('\tPor favor, ingrese solo una de las opciones planteadas.') 30 | else: 31 | print('Porfavor, hacer una exploracion fisica del paciente e indique si existe alguno de estos signos: ') 32 | print('\n\t1) Adenomegalias\n\t2) Heptomegalia\n\t3) Esplenomegalia\n\t4) Rastros de sangrado\n\t5) Lesiones infiltrtivas\n\t6) Ninguna') 33 | op = input('> Ingrese una opcion: ') 34 | if int(op) == 6: 35 | print('\tSu paciente Solo padece ese sintoma o debe diagnosticarlo de otra posible enfermedad.') 36 | elif int(op) < 1 or int(op) > 6: 37 | print('\tPor favor, ingrese solo una de las opciones planteadas.') 38 | else: 39 | print('Relice una biometria hematica e indique si el resultado es normal o no...') 40 | print('\n\t1) Normal\n\t2) Fuera de lo comun') 41 | op = input('> Ingrese una opcion: ') 42 | if int(op)==1: 43 | print('## PROCEDIMIENTO ##\n- Descartar patologias mas frecuentes de a cuerdo al grupo etareo.\n- Realizar los estudios confirmtorios apropiados\n- Aplicar tratamiento durante 15 dias') 44 | tr=input('Pasado los 15 dias, ¿hay mejoras en el paciente? (y/n): ') 45 | if tr.lower()=='y': 46 | print('Su paciente se ha recuperado, puede dar el alta.') 47 | elif tr.lower()=='n': 48 | print('El paciente se transfiere al especialista...') 49 | especialista() 50 | else: 51 | print('Debe ingresar una opción establecida.') 52 | elif int(op)==2: 53 | print('El paciente se transfiere al especialista...') 54 | especialista() 55 | else: 56 | print('Debe ingresar una opción establecida.') 57 | 58 | input() -------------------------------------------------------------------------------- /python/imprimir-factura.py: -------------------------------------------------------------------------------- 1 | #Software para gestion 2 | #@author Tomas Vargas 3 | 4 | import os 5 | 6 | print('## Facturacion ##\n====================\n') 7 | name=input('Nombre: ') 8 | Ci=input('CI: ') 9 | fecha=input('Fecha: ') 10 | print('====================') 11 | print('## Compra ##') 12 | prod=[] 13 | op='y' 14 | while(op=='y'): 15 | print('====================') 16 | p=[] 17 | p.append(input('Id del producto: ')) 18 | p.append(input('Nombre de producto: ')) 19 | p.append(input('Cantidad del producto: ')) 20 | p.append(input('Precio unitario: ')) 21 | prod.append(p) 22 | op=input('Desea agregar otro producto a la fctura? (y/n): ').lower() 23 | 24 | opf=input('¿Desea imprimir la factura? (y/n): ') 25 | os.system("cls") 26 | print('====================\n## FACTURA ##\n====================\n') 27 | print('Nombre: ', name, '\nCI: ', Ci, '\nFecha: ', fecha, '\n') 28 | sum=0 29 | for i in prod: 30 | print('\n====================') 31 | print('Id: ', i[0], '\nNombre de producto: ', i[1], '\nCantidad: ', i[2], '\nPrecio unitario: ', i[3]) 32 | sum+=float(i[3])*float(i[2]) 33 | print('\n====================') 34 | print('>> Total a pagar: ', sum) 35 | -------------------------------------------------------------------------------- /python/mostrar-hora-y-fecha.py: -------------------------------------------------------------------------------- 1 | #Software de sistema 2 | #Lenguaje python 3 | #author Tomas vargas 4 | 5 | #sistema para ver la hora y la fecha actual 6 | 7 | from datetime import date 8 | from datetime import datetime 9 | 10 | print("## SOFTWARE DE SISTEMA ##") 11 | 12 | td = date.today() 13 | now = datetime.today() 14 | name=input("Hola, ingresa tu nombre para brindarte los datos de fecha y hora de tu sistema:") 15 | print("Hola ", name, " aqui esta la hora y fecha de tu sistema.") 16 | print("Hora {}:{}".format(now.hour, now.minute)) 17 | print("Fecha {}/{}/{}".format(now.day, now.month, now.year)) 18 | print(">> La fecha y hora actual se obtuvo del sistema por medio de las librerias importadas al inicio del código fuente.") 19 | 20 | input() 21 | 22 | -------------------------------------------------------------------------------- /python/numeros-primos.py: -------------------------------------------------------------------------------- 1 | """ 2 | ingresar un numero y determinar si es primo o no, el programa termina cuando no 3 | se desee ingresar mas, se debe mostrar cuantos numeros primos fueron ingresados 4 | y la suma de los numeros primos. 5 | 6 | @author Tomas Vargas 7 | """ 8 | opcion=1 9 | contador=0 10 | sumat=0 11 | numtot=1 12 | 13 | def primos(n): 14 | a=0 #----------------------auxiliar que ayuda a determinar cuantas veces es divisible un numero 15 | for i in range(1,n+1): 16 | if(n % i==0): #--------condicion para saber si un numero es divisible mas de 2 veces 17 | a=a+1 18 | if(a!=2): #----------------si el numero fue divisible mas de dos veces no puede ser primo 19 | print("No es primo") 20 | return False #--------------------------devuelve un valor falso 21 | else: #----------------------quiere decir que si un numero es divisible unicamente para 2 numeros, es primo 22 | print("Si es primo") 23 | return True #--------------------------devuelve un valor verdadero 24 | 25 | while opcion!=0: #-------------------el bucle se repetira hasta que apachurremos la opcion NO (0) 26 | n=int(input("Ingrese el numero: ")) 27 | if primos(n)==True: #------Esta condicion nos permite evaluar la funcion y si nos devuelve un TRUE se ejecutara el codigo 28 | contador+=1 29 | sumat=sumat+n 30 | opcion=int(input("Desea ingresar un nuevo valor? (SI=1 / NO=0): ")) 31 | if opcion==1: 32 | numtot+=1 33 | 34 | print("El total de numeros ingresados es: ",numtot) 35 | print ("En total hay ", contador, " numeros primos") 36 | print("La suma total de los numeros primos es : ", sumat) 37 | input() 38 | -------------------------------------------------------------------------------- /python/registro-de-estudiantes.py: -------------------------------------------------------------------------------- 1 | import io 2 | import os 3 | 4 | #guarda los datos linea por linea 5 | def save(data,fich,met): 6 | f = open(fich, met) 7 | for i in data: 8 | f.write(i) 9 | f.write("\n") 10 | f.close() 11 | 12 | #lee los datos sin el salto de linea con la funcion rstrip 13 | def read(): 14 | lista=[] 15 | f = open("Estudiantes.bin", "r") 16 | for lines in f.readlines(): 17 | lista.append(lines.rstrip('\n')) 18 | f.close() 19 | return lista 20 | 21 | def regest(): 22 | est=[] 23 | v=1 24 | while v==1: 25 | os.system("cls") 26 | print("### REGISTRAR ESTUDIANTE ###\n") 27 | est.append(input("Nombre: ")) 28 | while v==1: 29 | try: 30 | op=int(input("Desea registrar otro estudiante? (SI=1 | NO =0): ")) 31 | v=0 32 | except: 33 | print("Opcion invalida...") 34 | v=1 35 | if op==0: 36 | v=0 37 | save(est,"Estudiantes.bin","a") 38 | 39 | def deletest(): 40 | est=read() 41 | os.system("cls") 42 | print("### REGISTRAR ESTUDIANTE ###\n") 43 | e=input("escriba el nombre del estudiante: ") 44 | if e in est: 45 | est.pop(est.index(e)) 46 | save(est,"Estudiantes.bin","w") 47 | 48 | def consulta(): 49 | est=read() 50 | print("### CONSULTAR ESTUDIANTE ###\n") 51 | e=input("Ingrese el nombre del estudiante: ") 52 | if e in est: 53 | print("El estudiante ", e, "Si esta registrado.") 54 | else: 55 | print(e, " No se encuentra registrado...") 56 | 57 | def show(): 58 | est=read() 59 | print("### MOSTRAR ESTUDIANTES ###\n") 60 | for i in est: 61 | print("-> ", i,"\n") 62 | 63 | v=1 64 | while v==1: 65 | os.system("cls") 66 | print("### CONTROL DE REGISTRO ###") 67 | print("1) registra estudiante\n2) Eliminar estudiante\n3) Consultar registro\n4) Mostrar registro\n5) Salir") 68 | 69 | op=str(input("Ingrese una opcion: ")) 70 | 71 | if op=="1": 72 | regest() 73 | elif op=="2": 74 | deletest() 75 | elif op=="3": 76 | consulta() 77 | elif op=="4": 78 | show() 79 | elif op=="5": 80 | v=0 81 | else: 82 | print("Opcion invalida...") 83 | 84 | input() 85 | 86 | 87 | -------------------------------------------------------------------------------- /python/sistema-de-biblioteca.py: -------------------------------------------------------------------------------- 1 | import io 2 | import os 3 | 4 | def save(data): 5 | f = open("libros.txt", "a") 6 | for i in data: 7 | for j in i: 8 | f.write(str(j)) 9 | f.write(' ') 10 | f.write("\n") 11 | f.close() 12 | 13 | def read(): 14 | lista=[] 15 | f = open("libros.txt", "r") 16 | for lines in f.readlines(): 17 | line=lines.rstrip('\n') 18 | aux=list(line.split(" ")) 19 | aux.pop(-1) 20 | lista.append(aux) 21 | f.close() 22 | return lista 23 | 24 | def onlyn(var): 25 | return var.isdigit() 26 | 27 | def newbook(): 28 | books=[] 29 | v=1 30 | while v==1: 31 | os.system("cls") 32 | print("### REGISTRO DE LIBROS ###\n") 33 | aux=[] 34 | 35 | while v==1: 36 | cod=str(input("Ingrese el codigo: ")) 37 | 38 | if onlyn(cod)==True: 39 | v=0 40 | else: 41 | print("Codigo invalido...\n") 42 | v=1 43 | 44 | titulo=input("Ingrese el titulo: ") 45 | 46 | print("\n<< UBICACION >>") 47 | while v==1: 48 | est=str(input("Numero de estante: ")) 49 | if onlyn(est)==True: 50 | v=0 51 | else: 52 | print("Entrada invalida...\n") 53 | v=1 54 | 55 | while v==1: 56 | fil=str(input("Numero de fila: ")) 57 | if onlyn(fil)==True: 58 | v=0 59 | else: 60 | print("Entrada invalida...\n") 61 | v=1 62 | 63 | while v==1: 64 | col=str(input("Numero de columna: ")) 65 | if onlyn(col)==True: 66 | v=0 67 | else: 68 | print("Entrada invalida...\n") 69 | v=1 70 | aux.append(cod) 71 | aux.append(titulo) 72 | aux.append(est) 73 | aux.append(fil) 74 | aux.append(col) 75 | 76 | books.append(aux) 77 | 78 | op=str(input("Desea ingresar otro libro? (SI=1 | NO=0): ")) 79 | if op=="0": 80 | v=0 81 | 82 | save(books) 83 | 84 | def consulta(): 85 | books=read() 86 | print("### CONSULTAR LIBRO ###") 87 | v=1 88 | while v==1: 89 | cod=str(input("Ingrese el codigo: ")) 90 | if onlyn(cod)==True: 91 | v=0 92 | else: 93 | print("Codigo invalido...\n") 94 | 95 | for book in books: 96 | if cod in book: 97 | print("======================") 98 | print("Codigo: ",book[0]) 99 | print("Titulo: ",book[1]) 100 | print(" << UBICACION >>") 101 | print("Estante: ",book[2]) 102 | print("Fila: ",book[3]) 103 | print("Columna: ",book[4]) 104 | print("======================") 105 | find=1 106 | else: 107 | find=0 108 | if find==0: 109 | print("El libro no esta registrado en la biblioteca...") 110 | 111 | 112 | v=1 113 | while v==1: 114 | os.system("cls") 115 | print("### LIBRERIA ###") 116 | print("1) Agregar libro\n2) Consultar libro\n3) Salir") 117 | op=str(input("Ingrese una opcion: ")) 118 | if op=="1": 119 | newbook() 120 | elif op=="2": 121 | consulta() 122 | elif op=="3": 123 | v=0 124 | else: 125 | print("Opcion invalida...") 126 | input() 127 | --------------------------------------------------------------------------------