{"id":1242,"date":"2020-05-01T10:38:38","date_gmt":"2020-05-01T16:38:38","guid":{"rendered":"http:\/\/portafoliosfit.um.edu.mx\/sarahhdz\/?post_type=project&#038;p=1242"},"modified":"2020-05-01T11:08:06","modified_gmt":"2020-05-01T17:08:06","slug":"programacion-orientada-a-objetos-iii","status":"publish","type":"project","link":"https:\/\/portafoliosfit.um.edu.mx\/sarahhdz\/project\/programacion-orientada-a-objetos-iii\/","title":{"rendered":"Programaci\u00f3n orientada a objetos"},"content":{"rendered":"<p><div class=\"et_d4_element et_pb_section et_pb_section_0  et_pb_css_mix_blend_mode et_section_regular et_block_section\" >\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t<div class=\"et_d4_element et_pb_row et_pb_row_0  et_pb_css_mix_blend_mode et_block_row\">\n\t\t\t\t<div class=\"et_d4_element et_pb_column_4_4 et_pb_column et_pb_column_0  et_pb_css_mix_blend_mode et-last-child et_block_column\">\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t<div class=\"et_pb_module et_d4_element et_pb_post_title et_pb_post_title_0 et_pb_bg_layout_dark  et_pb_text_align_center et_pb_featured_bg\"   >\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t<div class=\"et_pb_title_container\">\n\t\t\t\t\t<h1 class=\"entry-title\"><\/h1>\n\t\t\t\t<\/div>\n\t\t\t\t\n\t\t\t<\/div><div class=\"et_pb_module et_d4_element et_pb_text et_pb_text_0  et_pb_text_align_left et_pb_bg_layout_light\">\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t<div class=\"et_pb_text_inner\"><h5 style=\"text-align: center\"><em><strong>Competencias: <\/strong>Desarrollar programas computacionales para distintas \u00e1reas de aplicaci\u00f3n, usando las mejores pr\u00e1cticas, herramientas y paradigmas.<\/em><\/h5><\/div>\n\t\t\t<\/div>\n\t\t\t<\/div>\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t<\/div>\n\t\t\t\t\n\t\t\t\t\n\t\t\t<\/div><div class=\"et_d4_element et_pb_section et_pb_section_1  et_pb_css_mix_blend_mode et_section_regular et_block_section\" >\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t<div class=\"et_d4_element et_pb_row et_pb_row_1  et_pb_css_mix_blend_mode et_block_row\">\n\t\t\t\t<div class=\"et_d4_element et_pb_column_1_3 et_pb_column et_pb_column_1  et_pb_css_mix_blend_mode et_block_column\">\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t<div class=\"et_pb_module et_d4_element et_pb_text et_pb_text_1  et_pb_text_align_left et_pb_bg_layout_light\">\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t<div class=\"et_pb_text_inner\"><blockquote>\n<h3><strong>Manejo de arreglos bidimensionales<\/strong><\/h3>\n<\/blockquote><\/div>\n\t\t\t<\/div><div class=\"et_pb_module et_d4_element et_pb_text et_pb_text_2  et_pb_text_align_left et_pb_bg_layout_light\">\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t<div class=\"et_pb_text_inner\"><p style=\"text-align: justify\">El objetivo del programa es crear matrices de n x n (filas x columnas), donde n es un numero entero ingresado por el usuario. Estas matrices deben ser de n\u00famero impar, as\u00ed que si se ingresa un n\u00famero par se le sumar\u00e1 uno para obtener un impar.<\/p>\n<p style=\"text-align: justify\">Posteriormente, se hace la escritura de la matriz donde se escriben los n\u00fameros de 1 hasta n x n siguiendo la regla para crear cuadros m\u00e1gicos.<\/p>\n<p style=\"text-align: justify\">Finalmente se hace la lectura e impresi\u00f3n de la nueva matriz.<\/p><\/div>\n\t\t\t<\/div>\n\t\t\t<\/div><div class=\"et_d4_element et_pb_column_2_3 et_pb_column et_pb_column_2  et_pb_css_mix_blend_mode et-last-child et_block_column\">\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t<div class=\"et_pb_module et_d4_element et_pb_toggle et_pb_toggle_0 et_pb_toggle_item  et_pb_toggle_close\">\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t<h5 class=\"et_pb_toggle_title\">MagicSquare<\/h5>\n\t\t\t\t<div class=\"et_pb_toggle_content clearfix\"><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">import java.util.Scanner;\r\npublic class MagicSquare{\r\n    public static void main (String args []){\r\n        System.out.print('\\u000c');\r\n        Scanner sc = new Scanner(System.in);\r\n        System.out.print(\" Ingresa un numero impar (si no te lo subire a impar):\");\r\n        int n = sc.nextInt();\r\n        \/\/subir a impar\r\n        if (n%2==0){\r\n            n++;\r\n        }\r\n\r\n        \/\/Escritura de la casilla central de arriba\r\n        int [][] arr = new int [n][n];\r\n        int fa=0, ca=n\/2;\r\n        arr[fa][ca] = 1;\r\n        int fn=0, cn=0;\r\n        \r\n        \/\/Escritura de las demas casillas\r\n        for(int numero=2; numero&lt;=n*n; numero++){\r\n            \/\/int fn=0;\r\n            fn = fa-1;\r\n            if(fn&lt;0){\r\n                fn = n-1;\r\n            }\r\n            \/\/operador terciario para fn = condicion ? verdadero : falso.\r\n            \/\/fn = (fa-1)&lt;0 ? n-1 : fa-1;\r\n            \/\/int cn=0;\r\n            \r\n            cn=ca+1;\r\n            if(cn==n){\r\n                cn=0;\r\n            }\r\n            \/\/operador terciario para cn\r\n            \/\/cn = (ca+1)&gt;n ? 0 : ca+1;\r\n            \r\n            if(arr[fn][cn]==0){ \r\n                arr[fn][cn]=numero;\r\n                fa=fn;\r\n                ca=cn;\r\n            } else{\r\n                fa++;\r\n                arr[fa][ca]=numero;\r\n            }\r\n        }\r\n        \r\n        \/\/Lectura e impresion de la matriz\r\n        for (int f=0; f&lt;arr.length; f++)\r\n        {\r\n            for (int c=0; c&lt;arr[f].length; c++)\r\n            {\r\n                if (arr[f][c]&lt;10){\r\n                    System.out.print(\" \"+arr[f][c]+\" \");\r\n                } else {\r\n                    System.out.print(arr[f][c]+\" \");\r\n                }\r\n            }\r\n            System.out.println();\r\n        }\r\n    }\r\n}<\/pre><\/div>\n\t\t\t<\/div>\n\t\t\t<\/div>\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t<\/div>\n\t\t\t\t\n\t\t\t\t\n\t\t\t<\/div><div class=\"et_d4_element et_pb_section et_pb_section_2  et_pb_css_mix_blend_mode et_section_regular et_block_section\" >\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t<div class=\"et_d4_element et_pb_row et_pb_row_2  et_pb_css_mix_blend_mode et_block_row\">\n\t\t\t\t<div class=\"et_d4_element et_pb_column_1_3 et_pb_column et_pb_column_3  et_pb_css_mix_blend_mode et_block_column\">\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t<div class=\"et_pb_module et_d4_element et_pb_text et_pb_text_3  et_pb_text_align_left et_pb_bg_layout_light\">\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t<div class=\"et_pb_text_inner\"><blockquote>\n<h3><strong>Manejo de Strings<\/strong><\/h3>\n<\/blockquote><\/div>\n\t\t\t<\/div><div class=\"et_pb_module et_d4_element et_pb_text et_pb_text_4  et_pb_text_align_left et_pb_bg_layout_light\">\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t<div class=\"et_pb_text_inner\"><p style=\"text-align: justify\">Consiste en un decodificador de mensajes. Para codificar estos mensajes se hizo una matriz de n x m\u00a0 (donde n son las filas y m las columnas) y que se recorr\u00eda diagonalmente. Finalmente, se ordenaba esa matriz de izquierda a derecha en un String restando uno a cda letra en c\u00f3digo ASCII .<\/p>\n<p style=\"text-align: justify\">Por lo tanto, para decodificar el mensaje es necesario acomodar nuevamente el string en un arreglo con las mismas dimensiones que el original.<\/p>\n<p style=\"text-align: justify\">Se pide al usuario que ingrese el numero de filas, el numero de columnas y el mensaje codificado. Posterormente, se escribe el mensaje en la matriz de manera diagonal. Despu\u00e9s se lee e imprime de izquierda a derecha.<\/p>\n<p style=\"text-align: justify\">Distintos m\u00e9todos nos permiten trabajar con String. Estos tambi\u00f1e son un tipo de arreglo, ya que podemos seleccionar un caracter en un \u00edndice determinado.<\/p><\/div>\n\t\t\t<\/div>\n\t\t\t<\/div><div class=\"et_d4_element et_pb_column_2_3 et_pb_column et_pb_column_4  et_pb_css_mix_blend_mode et-last-child et_block_column\">\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t<div class=\"et_pb_module et_d4_element et_pb_toggle et_pb_toggle_1 et_pb_toggle_item  et_pb_toggle_close\">\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t<h5 class=\"et_pb_toggle_title\">Desafio02<\/h5>\n\t\t\t\t<div class=\"et_pb_toggle_content clearfix\"><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">import java.util.Scanner;\r\n\/*\r\n7 4\r\nUH-LDD-HRC-SQRMQ@DMNNTDCCNLK\r\n4 3\r\nFHH-MMQ-HDD@\r\n3 5\r\nGMY@QDQDC@GMR-@\r\n *\/\r\npublic class Desfio02\r\n{\r\n    public static void main (String args[])\r\n    {\r\n        System.out.print('\\u000c');\r\n        Scanner sc = new Scanner(System.in);\r\n        int rows = sc.nextInt();\r\n        int columns = sc.nextInt();\r\n        while (rows&lt;2 || rows&gt;20)\r\n        {\r\n            rows = sc.nextInt();\r\n            columns = sc.nextInt();\r\n        }\r\n        \/\/mensaje\r\n        sc.nextLine();\r\n        String message = sc.nextLine();\r\n        \/\/Decodificando mensaje\r\n        int index = 0;\r\n        char [][] matrix = new char[rows][columns];\r\n        for(int c=columns-1; c&gt;=0; c--)\r\n        {\r\n            for(int f=0; f&lt;rows;f++)\r\n            {\r\n                if ((message.charAt(index)+0)==45)\r\n                matrix[f][c] = message.charAt(index);\r\n                else\r\n                matrix[f][c] = (char)(message.charAt(index)+1);\r\n                index++;\r\n            }\r\n        }\r\n        \/\/imprimir mensaje decodificado\r\n        for(int f=0; f&lt;matrix.length; f++)\r\n        {\r\n            for(int c=0; c&lt;matrix[f].length;c++)\r\n            {\r\n                System.out.print(matrix[f][c]);\r\n            }\r\n        }\r\n    }\r\n}<\/pre><\/div>\n\t\t\t<\/div>\n\t\t\t<\/div>\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t<\/div>\n\t\t\t\t\n\t\t\t\t\n\t\t\t<\/div><div class=\"et_d4_element et_pb_section et_pb_section_3  et_pb_css_mix_blend_mode et_section_regular et_block_section\" >\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t<div class=\"et_d4_element et_pb_row et_pb_row_3  et_pb_css_mix_blend_mode et_block_row\">\n\t\t\t\t<div class=\"et_d4_element et_pb_column_1_3 et_pb_column et_pb_column_5  et_pb_css_mix_blend_mode et_block_column\">\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t<div class=\"et_pb_module et_d4_element et_pb_text et_pb_text_5  et_pb_text_align_left et_pb_bg_layout_light\">\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t<div class=\"et_pb_text_inner\"><blockquote>\n<h3><strong>Manejo de condicionales<\/strong><\/h3>\n<\/blockquote><\/div>\n\t\t\t<\/div><div class=\"et_pb_module et_d4_element et_pb_text et_pb_text_6  et_pb_text_align_left et_pb_bg_layout_light\">\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t<div class=\"et_pb_text_inner\"><p style=\"text-align: justify\">Tenemos n cantidad de piezas y queremos saber:<\/p>\n<p>\u00bfCu\u00e1ntas piezas tienen un peso entre 7.8 y 12.4 kg?<\/p>\n<p>\u00bfCu\u00e1ntas con mas de 12.4 kg.?<\/p>\n<p style=\"text-align: justify\">\u00bfCu\u00e1ntas con menos de 7.8 kg.?<\/p>\n<p>y \u00bfCu\u00e1l es la cantidad de piezas pesadas?<\/p>\n<p style=\"text-align: justify\">Para esto creamos cuatro variables contadores que incrementan seg\u00fan si hay una nueva pieza, si el peso de la pieza est\u00f1a entre 7.8 y 12.4 kg, si es mayor que 12.4 o menor de 7.8 kg.<\/p><\/div>\n\t\t\t<\/div>\n\t\t\t<\/div><div class=\"et_d4_element et_pb_column_2_3 et_pb_column et_pb_column_6  et_pb_css_mix_blend_mode et-last-child et_block_column\">\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t<div class=\"et_pb_module et_d4_element et_pb_toggle et_pb_toggle_2 et_pb_toggle_item  et_pb_toggle_close\">\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t<h5 class=\"et_pb_toggle_title\">Piezas<\/h5>\n\t\t\t\t<div class=\"et_pb_toggle_content clearfix\"><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">import java.util.Scanner;\r\npublic class Piezas\r\n{\r\n    public static void main (String args[])\r\n    {\r\n        System.out.print('\\u000c');\r\n        Scanner sc = new Scanner(System.in);\r\n        System.out.println(\"Ingrese el peso en kg de las piezas (escribir un '0' para terminar el programa)-\");\r\n        int piezas = 0, evaluacion1 = 0, evaluacion2 = 0, evaluacion3 = 0;\r\n        float peso = 1;\r\n        while (peso!=0)\r\n        {\r\n            peso = sc.nextFloat();\r\n            if (peso&gt;7.8&amp;&amp;peso&lt;12.4){\r\n                evaluacion1++;\r\n            }\r\n            if (peso&gt;12.5){\r\n                evaluacion2++;\r\n            }\r\n            if (peso&lt;7.8&amp;&amp;peso!=0){\r\n                evaluacion3++;\r\n            }\r\n            if (peso!=0){\r\n                piezas++;\r\n            }\r\n        }\r\n        System.out.println(\"\u00bfCu\u00e1ntas piezas tienen un peso entre 7.8 y 12.4 kg.? \"+evaluacion1);\r\n        System.out.println(\"\u00bfCu\u00e1ntas con mas de 12.4 kg.? \"+evaluacion2);\r\n        System.out.println(\"\u00bfCu\u00e1ntas con menos de 7.8 kg.? \"+evaluacion3);\r\n        System.out.println(\"Cantidad total de piezas procesadas: \"+piezas);\r\n    }\r\n}\r\n<\/pre><\/div>\n\t\t\t<\/div>\n\t\t\t<\/div>\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t<\/div>\n\t\t\t\t\n\t\t\t\t\n\t\t\t<\/div><div class=\"et_d4_element et_pb_section et_pb_section_4  et_pb_css_mix_blend_mode et_section_regular et_block_section\" >\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t<div class=\"et_d4_element et_pb_row et_pb_row_4  et_pb_css_mix_blend_mode et_block_row\">\n\t\t\t\t<div class=\"et_d4_element et_pb_column_1_3 et_pb_column et_pb_column_7  et_pb_css_mix_blend_mode et_block_column\">\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t<div class=\"et_pb_module et_d4_element et_pb_text et_pb_text_7  et_pb_text_align_left et_pb_bg_layout_light\">\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t<div class=\"et_pb_text_inner\"><blockquote>\n<h3><strong>Manejo de ciclos<\/strong><\/h3>\n<\/blockquote><\/div>\n\t\t\t<\/div><div class=\"et_pb_module et_d4_element et_pb_text et_pb_text_8  et_pb_text_align_left et_pb_bg_layout_light\">\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t<div class=\"et_pb_text_inner\"><p style=\"text-align: justify\">For, while, do-while, son ejemplos de ciclos de iteraci\u00f3n. Estos ciclos permiten repetir un proceeso infinidad de veces hasta que se rompa una condici\u00f3n.<\/p>\n<p style=\"text-align: justify\">En este ejercicio vimos el ciclo de do-while para sacar el factorial de un n\u00famero. Lo interesante de este ciclo es la realizaci\u00f3n primero de las intrucciones antes de evaluar la condici\u00f3n.<\/p>\n<p style=\"text-align: justify\">Antes para m\u00ed parec\u00eda algo innecesario si ya existe un ciclo while, pero ahora me he dado cuenta que este ciclo tiene su uso indispensable en algunos programas.<\/p>\n<p style=\"text-align: justify\">Aunque se podr\u00eda resolver un mismo problema con cualquiera de los ciclos el simple hecho de adaptarlos, cada uno nos facilita m\u00e1s una respectiva tarea.<\/p><\/div>\n\t\t\t<\/div>\n\t\t\t<\/div><div class=\"et_d4_element et_pb_column_2_3 et_pb_column et_pb_column_8  et_pb_css_mix_blend_mode et-last-child et_block_column\">\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t<div class=\"et_pb_module et_d4_element et_pb_toggle et_pb_toggle_3 et_pb_toggle_item  et_pb_toggle_close\">\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t<h5 class=\"et_pb_toggle_title\">Factorial<\/h5>\n\t\t\t\t<div class=\"et_pb_toggle_content clearfix\"><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">import java.util.Scanner;\r\n\r\npublic class Factorial\r\n{\r\n    public static void main (String args[])\r\n    {\r\n        System.out.print('\\u000c');\r\n        Scanner leer = new Scanner(System.in);\r\n        long n, m, factorial;\r\n        do\r\n        {\r\n            System.out.println(\"n factorial de un valor comprendido entre 2 y 20\");\r\n            n = leer.nextInt();\r\n            System.out.print(n+\"! = \");\r\n            for (m = n, factorial = 1; m&gt;=1; factorial*=m--)\r\n            if (m!=1)\r\n            System.out.print(m+\"x\");\r\n            else\r\n            System.out.print(m+\" = \");\r\n            System.out.println(factorial);\r\n        }\r\n        while(n&gt;=2 &amp;&amp; n&lt;=20);\r\n    }\r\n}\r\n<\/pre><\/div>\n\t\t\t<\/div>\n\t\t\t<\/div>\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t<\/div>\n\t\t\t\t\n\t\t\t\t\n\t\t\t<\/div><div class=\"et_d4_element et_pb_section et_pb_section_5  et_pb_css_mix_blend_mode et_section_regular et_block_section\" >\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t<div class=\"et_d4_element et_pb_row et_pb_row_5  et_pb_css_mix_blend_mode et_block_row\">\n\t\t\t\t<div class=\"et_d4_element et_pb_column_1_3 et_pb_column et_pb_column_9  et_pb_css_mix_blend_mode et_block_column\">\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t<div class=\"et_pb_module et_d4_element et_pb_text et_pb_text_9  et_pb_text_align_left et_pb_bg_layout_light\">\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t<div class=\"et_pb_text_inner\"><blockquote>\n<h3><strong>Manejo de herencia<\/strong><\/h3>\n<\/blockquote><\/div>\n\t\t\t<\/div><div class=\"et_pb_module et_d4_element et_pb_text et_pb_text_10  et_pb_text_align_left et_pb_bg_layout_light\">\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t<div class=\"et_pb_text_inner\"><p style=\"text-align: justify\">Tenemos que contar la menor cantidad de fuerza que utiliza un idividuo para moverse en un cuadro con centro 0 y cuatro posiciones a su alrededor.<\/p>\n<p style=\"text-align: justify\">Para esto se cre\u00f3 una clase individuo que nos devleve la posicion de cada uno de los pies de la persona, y asu vez nos permite cambiar la posicion de sus pies con un set cuando el movimiento sea el que mnor unidades de fuerza consume.<\/p>\n<p style=\"text-align: justify\">Para esto es necesario evaluar la posici\u00f3n actual de cada pie y la cantidad de unidades que se consumen al moverse en cada una de las 4 posibles posiciones. Finalmente, movemos el respectivo pie a la posici\u00f3n con menor fuerza consumida y agregamos esa cantidad de fuerza a una variable que mida la cantida de fuerza.<\/p><\/div>\n\t\t\t<\/div>\n\t\t\t<\/div><div class=\"et_d4_element et_pb_column_2_3 et_pb_column et_pb_column_10  et_pb_css_mix_blend_mode et-last-child et_block_column\">\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t<div class=\"et_pb_module et_d4_element et_pb_tabs et_pb_tabs_0 \" >\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t<ul class=\"et_pb_tabs_controls clearfix\">\n\t\t\t\t\t<li class=\"et_pb_tab_0 et_pb_tab_active\"><a href=\"#\">Individuo<\/a><\/li><li class=\"et_pb_tab_1\"><a href=\"#\">Desafio05<\/a><\/li>\n\t\t\t\t<\/ul>\n\t\t\t\t<div class=\"et_pb_all_tabs\">\n\t\t\t\t\t<div class=\"et_d4_element et_pb_tab et_pb_tab_0 clearfix et_pb_active_content\">\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t<div class=\"et_pb_tab_content\"><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">public class Individuo {\r\n    private int pd = 0;\r\n    private int pi = 0;\r\n    private int units = 0;\r\n    public int getPd(){\r\n        return pd;\r\n    }\r\n    public void setPd(int pd){\r\n        this.pd = pd;\r\n    }\r\n    public int getPi(){\r\n        return pi;\r\n    }\r\n    public void setPi(int pi){\r\n        this.pi = pi;\r\n    }\r\n    public int getUnits(){\r\n        return units;\r\n    }\r\n    public void setUnits(int units){\r\n        this.units = units;\r\n    }\r\n}\r\n<\/pre><\/div>\n\t\t\t<\/div><div class=\"et_d4_element et_pb_tab et_pb_tab_1 clearfix\">\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t<div class=\"et_pb_tab_content\"><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">import java.util.Scanner;\r\n\r\n\/\/1 2 2 4 0 1 2 3 4 1 2 3 3 4 2 0 0\r\npublic class Desafio05\r\n{\r\n    public static void main (String args[]) {\r\n        System.out.print('\\u000c');\r\n        Scanner tec = new Scanner (System.in);\r\n        int pos;\r\n        String seq;\r\n        Individuo white = new Individuo();\r\n        do{\r\n        white.setUnits(0);    \r\n        seq = \"\";\r\n        do {\r\n            pos = tec.nextInt();\r\n            seq = seq + pos;\r\n        }while(pos!=0);\r\n        int ud, ui;\r\n        for (int n = 0; n&lt;seq.length()-1; n++) {\r\n            ud = 0;\r\n            ui = 0;\r\n            \r\n            if (Math.abs(white.getPd()-seq.charAt(n))==1 || Math.abs(white.getPd()-seq.charAt(n))==3)\r\n            ud = 3;\r\n            if (Math.abs(white.getPd()-seq.charAt(n))==2)\r\n            ud = 4;\r\n            if (Math.abs(white.getPd()-seq.charAt(n))==0)\r\n            ud = 1;\r\n            if (Math.abs(white.getPd()-seq.charAt(n))==seq.charAt(n))\r\n            ud = 2;\r\n            \r\n            if (Math.abs(white.getPi()-seq.charAt(n))==1 || Math.abs(white.getPd()-seq.charAt(n))==3)\r\n            ui = 3;\r\n            if (Math.abs(white.getPi()-seq.charAt(n))==2)\r\n            ui = 4;\r\n            if (Math.abs(white.getPi()-seq.charAt(n))==0)\r\n            ui = 1;\r\n            if (Math.abs(white.getPi()-seq.charAt(n))==seq.charAt(n))\r\n            ui = 2;\r\n            \r\n            if (ui&lt;ud) {\r\n                white.setUnits(white.getUnits()+ui);\r\n                white.setPi(seq.charAt(n));\r\n            }else if (ud&lt;ui) {\r\n                white.setUnits(white.getUnits()+ud);\r\n                white.setPd(seq.charAt(n));\r\n            } else if (ud ==ui) {\r\n                white.setUnits(white.getUnits()+ud);\r\n                white.setPd(seq.charAt(n));\r\n            }\r\n        }\r\n        if (white.getUnits()==0)\r\n        break;\r\n        System.out.println(white.getUnits());\r\n    }while (!seq.contentEquals(\"00\"));\r\n    }\r\n}<\/pre><\/div>\n\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t<\/div>\n\t\t\t<\/div>\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t<\/div>\n\t\t\t\t\n\t\t\t\t\n\t\t\t<\/div><div class=\"et_d4_element et_pb_section et_pb_section_6  et_pb_css_mix_blend_mode et_section_regular et_block_section\" >\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t<div class=\"et_d4_element et_pb_row et_pb_row_6  et_pb_css_mix_blend_mode et_block_row\">\n\t\t\t\t<div class=\"et_d4_element et_pb_column_1_3 et_pb_column et_pb_column_11  et_pb_css_mix_blend_mode et_block_column\">\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t<div class=\"et_pb_module et_d4_element et_pb_text et_pb_text_11  et_pb_text_align_left et_pb_bg_layout_light\">\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t<div class=\"et_pb_text_inner\"><blockquote>\n<h3><strong>Juegos y programas hechos en clase<\/strong><\/h3>\n<\/blockquote><\/div>\n\t\t\t<\/div><div class=\"et_pb_module et_d4_element et_pb_text et_pb_text_12  et_pb_text_align_left et_pb_bg_layout_light\">\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t<div class=\"et_pb_text_inner\"><p style=\"text-align: justify\">Realizamos como proyecto final un juego en equipo. El juego consist\u00eda en un cubeOban donde la figura se arrastra y mueve hasta chocar con la pared m\u00e1s pr\u00f3xima. El objetivo es que cada cubo se encuentre con su punto del mismo color.<\/p>\n<p style=\"text-align: justify\">Son dos niveles y aqu\u00ed se adjuntan las fotos del dise\u00f1o de los mismos<\/p>\n<p style=\"text-align: justify\">Este proyecto fue muy interesante porque aplicamos adem\u00e1s de l\u00f3gica la interfaz que el usuario deb\u00eda usar y que fuera tambi\u00e9n atractiva.<\/p><\/div>\n\t\t\t<\/div>\n\t\t\t<\/div><div class=\"et_d4_element et_pb_column_2_3 et_pb_column et_pb_column_12  et_pb_css_mix_blend_mode et-last-child et_block_column\">\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t<div class=\"et_pb_module et_d4_element et_pb_tabs et_pb_tabs_1 \" >\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t<ul class=\"et_pb_tabs_controls clearfix\">\n\t\t\t\t\t<li class=\"et_pb_tab_2 et_pb_tab_active\"><a href=\"#\">Nivel1<\/a><\/li><li class=\"et_pb_tab_3\"><a href=\"#\">Nivel2<\/a><\/li>\n\t\t\t\t<\/ul>\n\t\t\t\t<div class=\"et_pb_all_tabs\">\n\t\t\t\t\t<div class=\"et_d4_element et_pb_tab et_pb_tab_2 clearfix et_pb_active_content\">\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t<div class=\"et_pb_tab_content\"><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">import javax.swing.JFrame;\r\nimport javax.swing.JPanel;\r\nimport javax.swing.JButton;\r\nimport javax.swing.JOptionPane;\r\nimport java.awt.event.MouseListener;\r\nimport java.awt.event.MouseEvent;\r\nimport java.awt.Dimension;\r\nimport java.awt.Container;\r\nimport java.awt.FlowLayout;\r\nimport java.awt.Color;\r\n\r\npublic class Nivel1Edg extends JFrame implements MouseListener{\r\n    int botonSize=80; \/\/tama\u00f1o de los botones \r\n    int xRatonAnt, yRatonAnt, xRatonAct, yRatonAct; \/\/ posiciones del raton en el panel\r\n    int botonPressed; \/\/1=boton 1, 2=boton 2, 0=ninguno\r\n    int f1=1, c1=1, f2=4, c2=6; \/\/fila y columna de los botones boton 1 y boton 2\r\n    int fGanar1=4, cGanar1=7; \/\/ fila y columna de ganar boton 1\r\n    int fGanar2=5, cGanar2=8; \/\/ganar boton 2\r\n    JButton meta1 = new RoundButton();\/\/botones de meta\r\n    JButton meta2 = new RoundButton();\r\n    JButton [][]botones = new JButton[10][12]; \/\/Matriz de botones\r\n    public static void main(String[] args) {\r\n        Nivel1Edg window = new Nivel1Edg();\r\n        window.setVisible(true);\r\n        window.setPreferredSize(new Dimension(980,870));\r\n        window.pack();\r\n        window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);\r\n    }\r\n    public Nivel1Edg(){\r\n        super(\"Nivel 1\");\r\n        Container contenedor = getContentPane();\r\n        contenedor.setLayout(new FlowLayout());\r\n\r\n        JPanel panel = new JPanel();\r\n        panel.setLayout(null);\r\n        panel.setPreferredSize(new Dimension(960,800));\r\n        panel.setBackground(Color.white);\r\n        contenedor.add(panel);\r\n        panel.addMouseListener(this);\r\n        \r\n        for (int f=0; f&lt;botones.length; f++) {\r\n            for(int c=0; c&lt;botones[f].length; c++) {\r\n                \/\/Colocar los botones de fondo del panel\r\n                if(f==0||f==botones.length-1||c==0||c==botones[f].length-1||(f==5&amp;&amp;c==1)||(f==4&amp;&amp;c==8)){\r\n                    botones[f][c]=new JButton();\r\n                    botones[f][c].setBounds(c*botonSize, f*botonSize, botonSize, botonSize);\r\n                    botones[f][c].setBackground(new Color(52,73,94));\r\n                    panel.add(botones[f][c]);\r\n                }\r\n                \/\/Colocar botones Rojos\r\n                if((f==f1&amp;&amp;c==c1)||(f==f2&amp;&amp;c==c2)){\r\n                    botones[f][c]=new JButton();\r\n                    if(f==f1&amp;&amp;c==c1){\r\n                        botones[f][c].setBackground(new Color(255,51,0));\r\n                    }else if(f==f2&amp;&amp;c==c2){\r\n                        botones[f][c].setBackground(new Color(0,126,229));\r\n                    }\r\n                    botones[f][c].setBounds(c*botonSize, f*botonSize, botonSize, botonSize);\r\n                    panel.add(botones[f][c]);\r\n                    botones[f][c].setBorder(null);\r\n                    botones[f][c].addMouseListener(this);\r\n                }\r\n            }\r\n        }\r\n        meta1.setBounds(cGanar1*botonSize,fGanar1*botonSize,botonSize,botonSize);\r\n        meta1.setBackground(new Color(255,51,0));\r\n        panel.add(meta1);\r\n        meta2.setBounds(cGanar2*botonSize,fGanar2*botonSize,botonSize,botonSize);\r\n        meta2.setBackground(new Color(0,126,229));\r\n        panel.add(meta2);\r\n    }\r\n    \r\n    public void mousePressed(MouseEvent e){\r\n        \/\/Coordenadas del raton ANTES\r\n        if (e.getSource()==botones[f1][c1]){\/\/Si el boton presionado es el boton 1\r\n            xRatonAnt=botones[f1][c1].getX()+e.getX();\r\n            yRatonAnt=botones[f1][c1].getY()+e.getY();\r\n            botonPressed=1;\r\n        } else if (e.getSource()==botones[f2][c2]) { \/\/Si el boton presionado es el boton 2\r\n            xRatonAnt=botones[f2][c2].getX()+e.getX();\r\n            yRatonAnt=botones[f2][c2].getY()+e.getY();\r\n            botonPressed=2;\r\n        } else\r\n            botonPressed=0;\r\n    }\r\n    public void mouseReleased(MouseEvent e){\r\n        \/\/Coordenadas del raton ACTUALES\r\n        if (e.getSource()==botones[f1][c1]) { \/\/Si el boton presionado fue el 1\r\n            xRatonAct=botones[f1][c1].getX()+e.getX();\r\n            yRatonAct=botones[f1][c1].getY()+e.getY();\r\n        } else if (e.getSource()==botones[f2][c2]) { \/\/Si el boton presionado fue el 2\r\n            xRatonAct=botones[f2][c2].getX()+e.getX();\r\n            yRatonAct=botones[f2][c2].getY()+e.getY();\r\n        }\r\n        for (int f=0; f&lt;botones.length; f++) {\r\n            for (int c=0; c&lt;botones[f].length; c++) {\r\n                if(f==0||f==botones.length-1||c==0||c==botones[f].length-1||(f==5&amp;&amp;c==1)||(f==4&amp;&amp;c==8)\r\n                ||(botonPressed==1&amp;&amp;f==f2&amp;&amp;c==c2)||(botonPressed==2&amp;&amp;f==f1&amp;&amp;c==c1)){ \/\/botones prohibidos\r\n                    if ((xRatonAct&gt;c*botonSize&amp;&amp;xRatonAct&lt;c*botonSize+botonSize)\r\n                    &amp;&amp;(yRatonAct&gt;f*botonSize&amp;&amp;yRatonAct&lt;f*botonSize+botonSize)) \/\/ Raton se levanta dentro de estos botones\r\n                    botonPressed=0; \/\/es como si ningun boton fue presionado\r\n                }\r\n            }\r\n        }\r\n        \r\n        \/\/DIRECCION del raton\r\n        int fAux=0, cAux=0;\r\n        if (Math.abs(yRatonAct-yRatonAnt)&gt;Math.abs(xRatonAct-xRatonAnt)&amp;&amp;botonPressed!=0) { \/\/Movimiento vertical\r\n            if (yRatonAct&gt;yRatonAnt) {\/\/hacia abajo\r\n                if (botonPressed==1) {\r\n                    fAux=f1;\r\n                    while(botones[fAux+1][c1]==null)\r\n                    fAux++;\r\n                    botones[fAux][c1]=botones[f1][c1];\r\n                    botones[f1][c1]=null;\r\n                    f1=fAux;\r\n                    botones[f1][c1].setLocation(c1*botonSize, f1*botonSize);\r\n                } \r\n                if (botonPressed==2) {\r\n                    fAux=f2;\r\n                    while(botones[fAux+1][c2]==null)\r\n                    fAux++;\r\n                    botones[fAux][c2]=botones[f2][c2];\r\n                    botones[f2][c2]=null;\r\n                    f2=fAux;\r\n                    botones[f2][c2].setLocation(c2*botonSize, f2*botonSize);\r\n                }\r\n            }\r\n            else if (yRatonAct&lt;yRatonAnt) {\/\/hacia arriba\r\n                if (botonPressed==1) {\r\n                    fAux=f1;\r\n                    while(botones[fAux-1][c1]==null)\r\n                    fAux--;\r\n                    botones[fAux][c1]=botones[f1][c1];\r\n                    botones[f1][c1]=null;\r\n                    f1=fAux;\r\n                    botones[f1][c1].setLocation(c1*botonSize, f1*botonSize);\r\n                }\r\n                if (botonPressed==2) {\r\n                    fAux=f2;\r\n                    while(botones[fAux-1][c2]==null)\r\n                    fAux--;\r\n                    botones[fAux][c2]=botones[f2][c2];\r\n                    botones[f2][c2]=null;\r\n                    f2=fAux;\r\n                    botones[f2][c2].setLocation(c2*botonSize, f2*botonSize);\r\n                }\r\n            }\r\n        } else if (Math.abs(yRatonAct-yRatonAnt)&lt;Math.abs(xRatonAct-xRatonAnt)&amp;&amp;botonPressed!=0) { \/\/Movimiento horizontal\r\n            if (xRatonAct&gt;xRatonAnt) {\/\/a la derecha\r\n                if (botonPressed==1) {\r\n                    cAux=c1;\r\n                    while(botones[f1][cAux+1]==null)\r\n                    cAux++;\r\n                    botones[f1][cAux]=botones[f1][c1];\r\n                    botones[f1][c1]=null;\r\n                    c1=cAux;\r\n                    botones[f1][c1].setLocation(c1*botonSize, f1*botonSize);\r\n                } else if (botonPressed==2) {\r\n                    cAux=c2;\r\n                    while(botones[f2][cAux+1]==null)\r\n                    cAux++;\r\n                    botones[f2][cAux]=botones[f2][c2];\r\n                    botones[f2][c2]=null;\r\n                    c2=cAux;\r\n                    botones[f2][c2].setLocation(c2*botonSize, f2*botonSize);\r\n                }\r\n            }\r\n            else if (xRatonAct&lt;xRatonAnt) {\/\/a la izquierda\r\n                if (botonPressed==1) {\r\n                    cAux=c1;\r\n                    while(botones[f1][cAux-1]==null)\r\n                    cAux--;\r\n                    botones[f1][cAux]=botones[f1][c1];\r\n                    botones[f1][c1]=null;\r\n                    c1=cAux;\r\n                    botones[f1][c1].setLocation(c1*botonSize, f1*botonSize);\r\n                } else if (botonPressed==2) {\r\n                    cAux=c2;\r\n                    while(botones[f2][cAux-1]==null)\r\n                    cAux--;\r\n                    botones[f2][cAux]=botones[f2][c2];\r\n                    botones[f2][c2]=null;\r\n                    c2=cAux;\r\n                    botones[f2][c2].setLocation(c2*botonSize, f2*botonSize);\r\n                }\r\n            }\r\n        }\r\n        \r\n        \/\/Ganar\r\n        if(c1==cGanar1 &amp;&amp; f1==fGanar1 &amp;&amp; c2==cGanar2 &amp;&amp; f2==fGanar2 )\r\n        {\r\n            JOptionPane.showMessageDialog(null,\"Nivel 1 - Completado\");\r\n            Nivel2Edg.main(null);\r\n            super.dispose();\r\n            \r\n        }\r\n    }\r\n    public void mouseClicked(MouseEvent e){}\r\n    public void mouseEntered(MouseEvent e){}\r\n    public void mouseExited(MouseEvent e){}\r\n}<\/pre><\/div>\n\t\t\t<\/div><div class=\"et_d4_element et_pb_tab et_pb_tab_3 clearfix\">\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t<div class=\"et_pb_tab_content\"><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">import javax.swing.JFrame;\r\nimport javax.swing.JPanel;\r\nimport javax.swing.JButton;\r\nimport javax.swing.JOptionPane;\r\nimport java.awt.event.MouseListener;\r\nimport java.awt.event.MouseEvent;\r\nimport java.awt.Dimension;\r\nimport java.awt.Container;\r\nimport java.awt.FlowLayout;\r\nimport java.awt.Color;\r\nimport java.awt.geom.*;\r\nimport javax.swing.*;\r\nimport javax.swing.border.Border;\r\nimport java.awt.Graphics;\r\nimport java.awt.Insets;\r\nimport java.awt.*;\r\nimport java.awt.event.*;\r\nimport java.awt.Component;\r\nclass Nivel2Edg extends JFrame implements MouseListener{\r\n    int botonSize=80; \/\/tama\u00f1o de los botones \r\n    int xRatonAnt, yRatonAnt, xRatonAct, yRatonAct; \/\/ posiciones del raton en el panel\r\n    int botonPressed; \/\/1=boton 1, 2=boton 2, 0=ninguno\r\n    int f1=1, c1=1, f2=1, c2=2, f3=1, c3=3, f4=1, c4=4; \/\/fila y columna de los botones boton 1 y boton 2\r\n    int fGanar1=3, cGanar1=2; \/\/ fila y columna de ganar boton 1\r\n    int fGanar2=6, cGanar2=7; \/\/ganar boton 2\r\n    int fGanar3=3, cGanar3=8; \/\/ fila y columna de ganar boton 1\r\n    int fGanar4=2, cGanar4=5; \/\/ganar boton 2\r\n    JButton meta1 = new RoundButton();\/\/botones de meta\r\n    JButton meta2 = new RoundButton();\r\n    JButton meta3 = new RoundButton();\/\/botones de meta\r\n    JButton meta4 = new RoundButton();\r\n    JButton [][]botones = new JButton[8][11]; \/\/Matriz de botones\r\n    public static void main(String[] args) {\r\n        Nivel2Edg window = new Nivel2Edg();\r\n        window.setVisible(true);\r\n        window.setPreferredSize(new Dimension(900,690));\r\n        window.pack();\r\n        window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);\r\n    }\r\n\r\n    public Nivel2Edg(){\r\n        super(\"Nivel 1\");\r\n        Container contenedor = getContentPane();\r\n        contenedor.setLayout(new FlowLayout());\r\n\r\n        JPanel panel = new JPanel();\r\n        panel.setLayout(null);\r\n        panel.setPreferredSize(new Dimension(880,640));\r\n        panel.setBackground(Color.white);\r\n        contenedor.add(panel);\r\n        panel.addMouseListener(this);\r\n        panel.setBackground(new Color(236,240,241));\r\n        for (int f=0; f&lt;botones.length; f++) {\r\n            for(int c=0; c&lt;botones[f].length; c++) {\r\n                \/\/Colocar los botones de fondo del panel\r\n                if(f==0||f==botones.length-1||c==0||c==botones[f].length-1|| c == 5 &amp;&amp; f==1 || c == 6 &amp;&amp; f==2 || c==8 &amp;&amp; f==2 || \r\n                c==1 &amp;&amp; f==3 || c==2 &amp;&amp; f==4 || c==4 &amp;&amp; f==4 || c==6 &amp;&amp; f==4 || c==7 &amp;&amp; f==5 || c==9 &amp;&amp; f==5 || c==4 &amp;&amp; f==6 || c==6 &amp;&amp; f==6 || c==9 &amp;&amp; f==6 || c==9 &amp;&amp; f==3){\r\n                    botones[f][c]=new JButton();\r\n                    botones[f][c].setBounds(c*botonSize, f*botonSize, botonSize, botonSize);\r\n                    botones[f][c].setBackground(new Color(52,73,94));\r\n                    panel.add(botones[f][c]);\r\n                }\r\n                \/\/Colocar botones Rojos\r\n                if((f==f1&amp;&amp;c==c1)||(f==f2&amp;&amp;c==c2) || (f==f3&amp;&amp;c==c3) || (f==f4&amp;&amp;c==c4)){\r\n                    botones[f][c]=new JButton();\r\n                    if(f==f1&amp;&amp;c==c1){\r\n                        botones[f][c].setBackground(new Color(255,51,0));\r\n                    }else if(f==f2&amp;&amp;c==c2){\r\n                        botones[f][c].setBackground(new Color(0,126,229));\r\n                    }else if(f==f3&amp;&amp;c==c3){\r\n                        botones[f][c].setBackground(new Color(9,184,62));\r\n                    }else if(f==f4&amp;&amp;c==c4){\r\n                        botones[f][c].setBackground(new Color(65,0,147));\r\n                    }\r\n                    botones[f][c].setBounds(c*botonSize, f*botonSize, botonSize, botonSize);\r\n                    panel.add(botones[f][c]);\r\n                    botones[f][c].addMouseListener(this);\r\n                }\r\n            }\r\n        }\r\n        meta1.setBounds(cGanar1*botonSize,fGanar1*botonSize,botonSize,botonSize);\r\n        meta1.setBackground(new Color(255,51,0));\r\n        panel.add(meta1);\r\n        meta2.setBounds(cGanar2*botonSize,fGanar2*botonSize,botonSize,botonSize);\r\n        meta2.setBackground(new Color(0,126,229));\r\n        panel.add(meta2);\r\n        meta3.setBounds(cGanar3*botonSize,fGanar3*botonSize,botonSize,botonSize);\r\n        meta3.setBackground(new Color(9,184,62));\r\n        panel.add(meta3);\r\n        meta4.setBounds(cGanar4*botonSize,fGanar4*botonSize,botonSize,botonSize);\r\n        meta4.setBackground(new Color(65,0,147));\r\n        panel.add(meta4);\r\n    }\r\n\r\n    public void mousePressed(MouseEvent e){\r\n        \/\/Coordenadas del raton ANTES\r\n        if (e.getSource()==botones[f1][c1]){\/\/Si el boton presionado es el boton 1\r\n            xRatonAnt=botones[f1][c1].getX()+e.getX();\r\n            yRatonAnt=botones[f1][c1].getY()+e.getY();\r\n            botonPressed=1;\r\n        } else if (e.getSource()==botones[f2][c2]) { \/\/Si el boton presionado es el boton 2\r\n            xRatonAnt=botones[f2][c2].getX()+e.getX();\r\n            yRatonAnt=botones[f2][c2].getY()+e.getY();\r\n            botonPressed=2;\r\n        } else if(e.getSource()==botones[f3][c3]){\r\n            xRatonAnt=botones[f3][c3].getX()+e.getX();\r\n            yRatonAnt=botones[f3][c3].getY()+e.getY();\r\n            botonPressed=3;\r\n        }else if(e.getSource()==botones[f4][c4]){\r\n            xRatonAnt=botones[f4][c4].getX()+e.getX();\r\n            yRatonAnt=botones[f4][c4].getY()+e.getY();\r\n            botonPressed=4;\r\n        }else\r\n            botonPressed=0;\r\n    }\r\n\r\n    public void mouseReleased(MouseEvent e){\r\n        \/\/Coordenadas del raton ACTUALES\r\n        if (e.getSource()==botones[f1][c1]) { \/\/Si el boton presionado fue el 1\r\n            xRatonAct=botones[f1][c1].getX()+e.getX();\r\n            yRatonAct=botones[f1][c1].getY()+e.getY();\r\n        } else if (e.getSource()==botones[f2][c2]) { \/\/Si el boton presionado fue el 2\r\n            xRatonAct=botones[f2][c2].getX()+e.getX();\r\n            yRatonAct=botones[f2][c2].getY()+e.getY();\r\n        } else if(e.getSource()==botones[f3][c3]){\r\n            xRatonAct=botones[f3][c3].getX()+e.getX();\r\n            yRatonAct=botones[f3][c3].getY()+e.getY();\r\n        }else if(e.getSource()==botones[f4][c4]){\r\n            xRatonAct=botones[f4][c4].getX()+e.getX();\r\n            yRatonAct=botones[f4][c4].getY()+e.getY();\r\n        }\r\n        for (int f=0; f&lt;botones.length; f++) {\r\n            for (int c=0; c&lt;botones[f].length; c++) {\r\n                if(f==0||f==botones.length-1||c==0||c==botones[f].length-1||(f==5&amp;&amp;c==1)||(f==4&amp;&amp;c==8)\r\n                ||(botonPressed==1&amp;&amp;f==f2&amp;&amp;c==c2)|| (botonPressed==1&amp;&amp;f==f3&amp;&amp;c==c3)||(botonPressed==1&amp;&amp;f==f4&amp;&amp;c==c4) ||\r\n                (botonPressed==2&amp;&amp;f==f1&amp;&amp;c==c1)|| (botonPressed==2&amp;&amp;f==f3&amp;&amp;c==c3)||(botonPressed==2&amp;&amp;f==f4&amp;&amp;c==c4)||\r\n                (botonPressed==3&amp;&amp;f==f2&amp;&amp;c==c2)|| (botonPressed==3&amp;&amp;f==f1&amp;&amp;c==c1)||(botonPressed==3&amp;&amp;f==f4&amp;&amp;c==c4)||\r\n                (botonPressed==4&amp;&amp;f==f2&amp;&amp;c==c2)|| (botonPressed==4&amp;&amp;f==f3&amp;&amp;c==c3)||(botonPressed==4&amp;&amp;f==f1&amp;&amp;c==c1)){ \/\/botones prohibidos\r\n                  if ((xRatonAct&gt;c*botonSize&amp;&amp;xRatonAct&lt;c*botonSize+botonSize)\r\n                    &amp;&amp;(yRatonAct&gt;f*botonSize&amp;&amp;yRatonAct&lt;f*botonSize+botonSize)) \/\/ Raton se levanta dentro de estos botones\r\n                        botonPressed=0; \/\/es como si ningun boton fue presionado\r\n                }\r\n            }\r\n        }\r\n\r\n        \/\/DIRECCION del raton\r\n        int fAux=0, cAux=0;\r\n        if (Math.abs(yRatonAct-yRatonAnt)&gt;Math.abs(xRatonAct-xRatonAnt)&amp;&amp;botonPressed!=0) { \/\/Movimiento vertical\r\n            if (yRatonAct&gt;yRatonAnt) {\/\/hacia abajo\r\n                if (botonPressed==1) {\r\n                    fAux=f1;\r\n                    while(botones[fAux+1][c1]==null)\r\n                        fAux++;\r\n                    botones[fAux][c1]=botones[f1][c1];\r\n                    botones[f1][c1]=null;\r\n                    f1=fAux;\r\n                    botones[f1][c1].setLocation(c1*botonSize, f1*botonSize);\r\n                } else if (botonPressed==2) {\r\n                    fAux=f2;\r\n                    while(botones[fAux+1][c2]==null)\r\n                        fAux++;\r\n                    botones[fAux][c2]=botones[f2][c2];\r\n                    botones[f2][c2]=null;\r\n                    f2=fAux;\r\n                    botones[f2][c2].setLocation(c2*botonSize, f2*botonSize);\r\n                } else if (botonPressed==3) {\r\n                    fAux=f3;\r\n                    while(botones[fAux+1][c3]==null)\r\n                        fAux++;\r\n                    botones[fAux][c3]=botones[f3][c3];\r\n                    botones[f3][c3]=null;\r\n                    f3=fAux;\r\n                    botones[f3][c3].setLocation(c3*botonSize, f3*botonSize);\r\n                } else if (botonPressed==4) {\r\n                    fAux=f4;\r\n                    while(botones[fAux+1][c4]==null)\r\n                        fAux++;\r\n                    botones[fAux][c4]=botones[f4][c4];\r\n                    botones[f4][c4]=null;\r\n                    f4=fAux;\r\n                    botones[f4][c4].setLocation(c4*botonSize, f4*botonSize);\r\n                }\r\n            }\r\n            else if (yRatonAct&lt;yRatonAnt) {\/\/hacia arriba\r\n                if (botonPressed==1) {\r\n                    fAux=f1;\r\n                    while(botones[fAux-1][c1]==null)\r\n                        fAux--;\r\n                    botones[fAux][c1]=botones[f1][c1];\r\n                    botones[f1][c1]=null;\r\n                    f1=fAux;\r\n                    botones[f1][c1].setLocation(c1*botonSize, f1*botonSize);\r\n                } else if (botonPressed==2) {\r\n                    fAux=f2;\r\n                    while(botones[fAux-1][c2]==null)\r\n                        fAux--;\r\n                    botones[fAux][c2]=botones[f2][c2];\r\n                    botones[f2][c2]=null;\r\n                    f2=fAux;\r\n                    botones[f2][c2].setLocation(c2*botonSize, f2*botonSize);\r\n                } else if (botonPressed==3) {\r\n                    fAux=f3;\r\n                    while(botones[fAux-1][c3]==null)\r\n                        fAux--;\r\n                    botones[fAux][c3]=botones[f3][c3];\r\n                    botones[f3][c3]=null;\r\n                    f3=fAux;\r\n                    botones[f3][c3].setLocation(c3*botonSize, f3*botonSize);\r\n                }else if (botonPressed==4) {\r\n                    fAux=f4;\r\n                    while(botones[fAux-1][c4]==null)\r\n                        fAux--;\r\n                    botones[fAux][c4]=botones[f4][c4];\r\n                    botones[f4][c4]=null;\r\n                    f4=fAux;\r\n                    botones[f4][c4].setLocation(c4*botonSize, f4*botonSize);\r\n                }\r\n            }\r\n        } else if (Math.abs(yRatonAct-yRatonAnt)&lt;Math.abs(xRatonAct-xRatonAnt)&amp;&amp;botonPressed!=0) { \/\/Movimiento horizontal\r\n            if (xRatonAct&gt;xRatonAnt) {\/\/a la derecha\r\n                if (botonPressed==1) {\r\n                    cAux=c1;\r\n                    while(botones[f1][cAux+1]==null)\r\n                        cAux++;\r\n                    botones[f1][cAux]=botones[f1][c1];\r\n                    botones[f1][c1]=null;\r\n                    c1=cAux;\r\n                    botones[f1][c1].setLocation(c1*botonSize, f1*botonSize);\r\n                } else if (botonPressed==2) {\r\n                    cAux=c2;\r\n                    while(botones[f2][cAux+1]==null)\r\n                        cAux++;\r\n                    botones[f2][cAux]=botones[f2][c2];\r\n                    botones[f2][c2]=null;\r\n                    c2=cAux;\r\n                    botones[f2][c2].setLocation(c2*botonSize, f2*botonSize);\r\n                }else if (botonPressed==3) {\r\n                    cAux=c3;\r\n                    while(botones[f3][cAux+1]==null)\r\n                        cAux++;\r\n                    botones[f3][cAux]=botones[f3][c3];\r\n                    botones[f3][c3]=null;\r\n                    c3=cAux;\r\n                    botones[f3][c3].setLocation(c3*botonSize, f3*botonSize);\r\n                } else if (botonPressed==4) {\r\n                    cAux=c4;\r\n                    while(botones[f4][cAux+1]==null)\r\n                        cAux++;\r\n                    botones[f4][cAux]=botones[f4][c4];\r\n                    botones[f4][c4]=null;\r\n                    c4=cAux;\r\n                    botones[f4][c4].setLocation(c4*botonSize, f4*botonSize);\r\n                }\r\n            }\r\n            else if (xRatonAct&lt;xRatonAnt) {\/\/a la izquierda\r\n                if (botonPressed==1) {\r\n                    cAux=c1;\r\n                    while(botones[f1][cAux-1]==null)\r\n                        cAux--;\r\n                    botones[f1][cAux]=botones[f1][c1];\r\n                    botones[f1][c1]=null;\r\n                    c1=cAux;\r\n                    botones[f1][c1].setLocation(c1*botonSize, f1*botonSize);\r\n                } else if (botonPressed==2) {\r\n                    cAux=c2;\r\n                    while(botones[f2][cAux-1]==null)\r\n                        cAux--;\r\n                    botones[f2][cAux]=botones[f2][c2];\r\n                    botones[f2][c2]=null;\r\n                    c2=cAux;\r\n                    botones[f2][c2].setLocation(c2*botonSize, f2*botonSize);\r\n                }else if (botonPressed==3) {\r\n                    cAux=c3;\r\n                    while(botones[f3][cAux-1]==null)\r\n                        cAux--;\r\n                    botones[f3][cAux]=botones[f3][c3];\r\n                    botones[f3][c3]=null;\r\n                    c3=cAux;\r\n                    botones[f3][c3].setLocation(c3*botonSize, f3*botonSize);\r\n                } else if (botonPressed==4) {\r\n                    cAux=c4;\r\n                    while(botones[f4][cAux-1]==null)\r\n                        cAux--;\r\n                    botones[f4][cAux]=botones[f4][c4];\r\n                    botones[f4][c4]=null;\r\n                    c4=cAux;\r\n                    botones[f4][c4].setLocation(c4*botonSize, f4*botonSize);\r\n                }\r\n            }\r\n        }\r\n\r\n        \/\/Ganar\r\n        if(c1==cGanar1 &amp;&amp; f1==fGanar1 &amp;&amp; c2==cGanar2 &amp;&amp; f2==fGanar2 &amp;&amp; c3==cGanar3 &amp;&amp; f3==fGanar3 &amp;&amp; c4==cGanar4 &amp;&amp; f4==fGanar4)\r\n        {\r\n            JOptionPane.showMessageDialog(null,\"Ultimo nivel completado\");\r\n            super.dispose();\r\n        }\r\n    }\r\n\r\n    public void mouseClicked(MouseEvent e){}\r\n\r\n    public void mouseEntered(MouseEvent e){}\r\n\r\n    public void mouseExited(MouseEvent e){}\r\n   \r\n}\r\n\r\nclass RoundButton extends JButton {\r\n\r\n    public RoundButton() {\r\n        setBackground(Color.lightGray);\r\n        setFocusable(false);\r\n        Dimension size = getPreferredSize();\r\n        size.width = size.height = 20;\r\n        setPreferredSize(size);\r\n        setContentAreaFilled(false);\r\n    }\r\n\r\n    protected void paintComponent(Graphics g) {\r\n        if (getModel().isArmed()) {\r\n            g.setColor(Color.gray);\r\n        } else {\r\n            g.setColor(getBackground());\r\n        }\r\n        g.fillOval(60\/2, 60\/2, 19, 19);\r\n        super.paintComponent(g);\r\n    }\r\n\r\n    protected void paintBorder(Graphics g) {\r\n        g.setColor(null);\r\n        g.drawOval(70\/2, 70\/2, 0, 0);\r\n    }\r\n    Shape forma;\r\n    public boolean contains(int x, int y) {\r\n        if (forma == null || !forma.getBounds().equals(getBounds())) {\r\n            forma = new Ellipse2D.Float(0, 0, getWidth(), getHeight());\r\n        }\r\n        return forma.contains(x, y);\r\n    }\r\n}<\/pre><\/div>\n\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t<\/div>\n\t\t\t<\/div>\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t<\/div>\n\t\t\t\t\n\t\t\t\t\n\t\t\t<\/div><div class=\"et_d4_element et_pb_section et_pb_section_7 et_pb_with_background  et_pb_css_mix_blend_mode et_section_regular et_block_section\" >\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t<div class=\"et_d4_element et_pb_row et_pb_row_7  et_pb_css_mix_blend_mode et_block_row\">\n\t\t\t\t<div class=\"et_d4_element et_pb_column_4_4 et_pb_column et_pb_column_13  et_pb_css_mix_blend_mode et-last-child et_block_column\">\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t<div class=\"et_pb_module et_d4_element et_pb_text et_pb_text_13  et_pb_text_align_left et_pb_bg_layout_light\">\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t<div class=\"et_pb_text_inner\"><h3>Reflexi\u00f3n<\/h3>\n<p>&nbsp;<\/p>\n<p>Las matrices son arreglos de dos dimensiones, donde cada indice del primer arreglo de filas contiene un arreglo de columnas. El uso correcto de lectura y escritura de las matrices facilita muchas tareas ya que podemos emplear recorridos en distintas direcciones seg\u00fan sea m\u00e1s conveniente.<\/p>\n<p>Adem\u00e1s de if, else como sentencias condicionales, puede ser pr\u00e1ctico utilizar switch si lo que queremos es evaluar que el valor de una variable sea uno espec\u00edfico.<\/p><\/div>\n\t\t\t<\/div>\n\t\t\t<\/div>\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t<\/div>\n\t\t\t\t\n\t\t\t\t\n\t\t\t<\/div><\/p>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":18,"featured_media":806,"comment_status":"open","ping_status":"closed","template":"","meta":{"_et_pb_use_builder":"on","_et_pb_old_content":"","_et_gb_content_width":"","footnotes":""},"project_category":[22],"project_tag":[],"class_list":["post-1242","project","type-project","status-publish","has-post-thumbnail","hentry","project_category-portafolio-iii"],"_links":{"self":[{"href":"https:\/\/portafoliosfit.um.edu.mx\/sarahhdz\/wp-json\/wp\/v2\/project\/1242","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/portafoliosfit.um.edu.mx\/sarahhdz\/wp-json\/wp\/v2\/project"}],"about":[{"href":"https:\/\/portafoliosfit.um.edu.mx\/sarahhdz\/wp-json\/wp\/v2\/types\/project"}],"author":[{"embeddable":true,"href":"https:\/\/portafoliosfit.um.edu.mx\/sarahhdz\/wp-json\/wp\/v2\/users\/18"}],"replies":[{"embeddable":true,"href":"https:\/\/portafoliosfit.um.edu.mx\/sarahhdz\/wp-json\/wp\/v2\/comments?post=1242"}],"version-history":[{"count":9,"href":"https:\/\/portafoliosfit.um.edu.mx\/sarahhdz\/wp-json\/wp\/v2\/project\/1242\/revisions"}],"predecessor-version":[{"id":1278,"href":"https:\/\/portafoliosfit.um.edu.mx\/sarahhdz\/wp-json\/wp\/v2\/project\/1242\/revisions\/1278"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/portafoliosfit.um.edu.mx\/sarahhdz\/wp-json\/wp\/v2\/media\/806"}],"wp:attachment":[{"href":"https:\/\/portafoliosfit.um.edu.mx\/sarahhdz\/wp-json\/wp\/v2\/media?parent=1242"}],"wp:term":[{"taxonomy":"project_category","embeddable":true,"href":"https:\/\/portafoliosfit.um.edu.mx\/sarahhdz\/wp-json\/wp\/v2\/project_category?post=1242"},{"taxonomy":"project_tag","embeddable":true,"href":"https:\/\/portafoliosfit.um.edu.mx\/sarahhdz\/wp-json\/wp\/v2\/project_tag?post=1242"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}