Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Informe Programa
Informe Programa
UNIVERSIDAD TECNICA DE MACHALA FACULTAD DE INGENIERA CIVIL ESCUELA DE INFORMTICA PRIMER QUIMESTRE PARALELO A PROGRAMACIN 1 UTILITARIOS 1
Jugando con la Naturaleza Proyecto Final de Asignatura Autores: Castro Vera Jorge Herman Guia Vivin Lus Fernando Reyes Ortz Marjorie Estefania Romero Espinoza Cristhian Armando Docente: Ing. Fausto Redrovn Castillo, Mg.
AUTORA: Nosotros, Catro Jorge, Guia Vivian Luis Fernando, Reyes Ortiz Marjorie Estefania y Romero Cristhian, como autores del presente trabajo de investigacin, somos responsables de las ideas, conceptos, procedimientos y resultados vertidos en la misma.
ndice de contenido
1.JUSTIFICACIN ..........................................................................................5 2.OBJETIVOS ................................................................................................6 2.1. Objetivo General ..................................................................................6 2.2.Objetivos Especficos ............................................................................6 3.- ANTECEDENTES .....................................................................................6 4.- MARCO TERICO ....................................................................................7 5.- MARCO METODOLGICO ......................................................................12 5.1 Anlisis de resultados .........................................................................12 5.2 Solucin ..............................................................................................12 6.- CONCLUSIONES ....................................................................................16 7.- RECOMENDACIONES ............................................................................17 9.- REFERENCIAS BIBLIOGRFICAS ............................................................17 10.- ANEXOS. .............................................................................................17 10.1.- Cdigo fuente del programa ...........................................................17 10.1.1 Algoritmo Menu...............................................................................17 10.1.2 Algortimo Presentacin...................................................................22 10.1.3 Algoritmo Sub Men........................................................................26 10.1.4 Algoritmo Arbol Juego.....................................................................36 10.1.5 Juego de Nombres de Animales......................................................60 10.1.6 Algoritmo Grupo Hervivoros............................................................66 10.1.7 Algoritmo Grupo Hervivoros 2.........................................................73 MANUAL DEL PROGRAMADOR....................................................................87 10.1.2 Algortimo Presentacin...................................................................92 10.1.3 Algoritmo Sub Men........................................................................96 MANUAL DEL USUARIO.............................................................................149
Proyecto Final de Programacin I Figura Figura Figura Figura Figura Figura Figura Figura Figura Figura Figura Figura Figura Figura 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: Mensaje Despues de Ingresar al Menu......................................82 Codigo del Mensaje...................................................................83 Imagen del Sub Men................................................................83 Codigo Fuente Del Sub Men....................................................84 Juego de Colocar las Partes del Arbol........................................85 Codigo Fuente del Juego de Colocas Las Partes Del Arbol.........86 Codigo del Juego de Colocar Las Partes del Arbol.....................86 Algoritmo Men.......................................................................149 Algoritmo Presentacin...........................................................149 Algorirmo Sub Men................................................................150 Arbol Juego..............................................................................150 Algoritmo Juego de Animales..................................................151 Algoritmo Grupo Hervivoros....................................................151 Algoritmo Grupo Hervivoros 2.................................................152
Proyecto Final de Programacin I 1.JUSTIFICACIN Actualmente el juego no es considerado como una mera forma de descargar la energa sobrante, las distintas teoras psicolgicas han puesto de manifiesto la importancia del juego dentro del desarrollo infantil, sobre todo en los primeros aos.En este sentido, los juegos de simulacin constituyen un ejemplo ms de las posibilidades pedaggicas de la conducta ldica. A la hora de ensear contenidos de las ciencias naturales, nos encontramos con la dificultad de plantear un aprendizaje activo de estos temas. Los juegos de simulacin imponen una posible solucin a estas limitaciones. Se trata de reproduccin de acontecimientos de la vida real, eliminando la informacin irrelevante, se secuencian los pasos y conseguimos que los alumnos afronten la necesidad de tomar una decisin y de valorar sus resultados. Las ventajas que presentan estos juegos son numerosas, aunque como principal ventaja destacaramos su capacidad de motivar e interesar a los alumnos.
Proyecto Final de Programacin I 2.OBJETIVOS 2.1. Objetivo General Preparar y poner a punto los recursos informticos y aprendizajes adquiridos en el transcurso del semestre, conocer el funcionamiento y la dinmica de los diferentes juegos educativos en los cuales influyan mtodos de contenido lgicos, seleccionando los que mejor se adapten a las caractersticas del alumnado; implementando la programacion de forma adecuada a las actividades basadas en la utilizacin de los mismos y evaluando la aplicacin de los juegos didcticos en el aula, obteniendo los resultados deseados. 2.2.Objetivos Especficos Evaluar la aplicacin del juego de lgica como estrategia de enseanzaaprendizaje para personas de temprana edad. Utilizar los juegos didcticos para hacer mas amena las actividades de evaluacin. Implementar una aplicacion pedagogica que permitar desarrollar la habilidad de plasmar sus conocimientos no solo de manera textual sino tambien a traves de un juego digital. 3.- ANTECEDENTES Es de hacer notar que los privilegios modernos relacionados con el proceso de enseanza-aprendizaje de los educandos, permite incluir al juego como una estrategia innovadora, eficaz y participativa para el desarrollo intelectual del alumno. De all, que han surgido en los ltimos tiempos diversas investigaciones y aportes que proponen al juego como alternativa novedosa para el aprendizaje. A continuacin se presentan una serie de trabajos que figuran como antecedentes de la investigacin planteada. Araujo y Valera (2006) disearon un estudio para promover el juego como estrategia de globalizacion del eje ambiente, dirigido a los docentes de la II etapa de Educacin Castro Guia Reyes Romero
6
Proyecto Final de Programacin I Basca, para lo cual se llevaron a cabo una recoleccin de la informacin, diseando un cuestionario tipo lickert1 que una vez aplicado y analizado su contenido logro concluir que los docentes si bien utilizan estrategias diversas, por lo que se considero la elaboracin de una propuesta que contiene un conjunto de juegos ecolgicos para desarrollar los alcances del eje transversal ambiente en la segunda etapa de educacin bsica. Por su parte Briceo y Villegas (2006) realizaron un estudio dirigido al diseo de estratiegias didcticas para la enseanza del sistema nervioso en el 8 grado de educacin bsica, planteada como una investigacin de tipo descriptivo la cual se llevo a cabo con una muestra de 140 alumnos, aplicndolos una prueba sobre los contenidos a desarrollar para medir los conocimientos previos sobre el tema. Seguidamente implementaron las estrategias diseadas entre ellas: juegos didcticos como el rompecabezas del cerebro y sopa de letras. Dichos juegos buscaban determinar la capacidad de reconocimiento de las partes del cerebro y la agilidad y destreza en la ejecucin de los mismos 4.- MARCO TERICO Investigacin Comentarios en Java Los comentarios, anotaciones en el cdigo que el compilador ignora pero son tiles para los programadores, existen en los lenguajes de programacin desde el principio. Desde hace mucho tiempo se observ que en realidad los comentarios se usaban para dos propsitos diferentes: Para explicar el propsito de sentencias o grupos de sentencias. Estos comentarios son tiles para el propio autor del cdigo, y para otros que quieran modificar ese cdigo. Comentarios explicando qu hace una "pieza" cerrada de cdigo. Estos comentarios
1 (tambin denominada mtodo de evaluaciones sumarias) se denomina as por Rensis Likert, quin public en 1932 un informe donde describa su uso. Es una escala psicomtrica comnmente utilizada en cuestionarios, y es la escala de uso ms amplio en encuestas para la investigacin, principalmente en ciencias sociales. 7
Proyecto Final de Programacin I son tiles para quien quiere utilizar esta "pieza" en su propio programa, y que por tanto est necesita saber lo que hace, no cmo se las ha arreglado el programador para conseguir este resultado. Al disear Java se distinguieron desde el principio ambas posibilidades. Para el primer tipo, comentarios "internos" se usan los caracteres // seguidos del comentario, o /* .... */ con el comentario en el lugar de los puntos suspensivos. La primera posibilidad indica que el resto de la lnea, tras las dos barras, es un comentario, mientras que la segunda se usa para comentarios de ms de una lnea. Por ejemplo, un fragmento de cdigo que calcula la suma 1+3+5+ ... +99 y muestra el resultado por pantalla: int suma = 0; // al principio la suma vale 0 // vamos sumando cada uno de los cuadrados entre 1 y 100 y acumulando el resultado for (int i=1; i<=99; i+=2) suma += i; // finalmente mostramos el resultado por pantalla System.out.println(suma); // por cierto, que valor se mostrar por pantalla? El segundo tipo, los usados para explicar qu hace un cdigo son los llamados en Java comentarios JavaDoc, y se escriben comenzando por /** y terminando con */ , pudiendo ocupar varias lneas. Mientras que los comentarios usuales no tienen ningn formato, los comentarios JavaDoc siguen una estructura prefijada que describimos en el siguiente apartado. JavaDoc Este artculo es el inicio de una serie de ellos dedicados a aprender cmo comentar el cdigo Java y cmo generar la documentacin HTML de nuestras API's mediante la herramienta de generacin automtica JavaDoc. Como mi mentor en Java me dijo una vez, el buen cdigo en Java se comenta solo y no le falta razn. Por eso, aqu vamos a aprender que no es necesario comentar todas las lneas de cdigo (salvo algn caso excepcional que requiera ser remarcado por su importancia). Realmente lo nico necesario es comentar la clase y cada uno de los mtodos que Castro Guia Reyes Romero
8
Proyecto Final de Programacin I empleemos, bien para quien quiera entender qu hace esa clase o la funcin que desempean cada uno de los mtodos o bien, como es la intencin de este artculo para que luego la herramienta de generacin automtica de documentacin nos cree la nuestra. En este primer artculo nos dedicaremos a aprender cmo se comentan las clases y las etiquetas que disponemos para aadir informacin adicional. Tipo de comentario para generar la documentacin. A parte de los ya sabidos /* */ //, tambin tenemos un tercero propio de java y que es el que usa el JavaDoc como delimitador para reconocer la documentacin que tiene que generar. Cualquier comentario de este tipo debe comenzar por el delimitador /** y, luego, cada lnea de comentario que aadamos debe seguir al operador *. As mismo, tambin comenzarn por un * las etiquetas, slo que stas a su vez deben ser precedidas por el operador @ como se ver en el prximo captulo. Una cosa muy importante que quiero resaltar ya es que javadoc lo nico que hace es copiar el contenido a una pgina HTML por lo que se admite cualquier etiqueta HTML que queris para darle ms claridad o vistosidad a vuestra documentacin. Vemos a continuacin el formato tpico de un comentario al estilo javadoc. /** * Al usar este estilo de comentario estoy consiguiendo que cuando * lo pase por JavaDoc, esta herramienta copie este texto a una pgina * html. * Puedes ver que tambin admite <b>etiquetas HTML</b> * y sto ltimo que acabo de escribir aparecer en negrita. */ Las etiquetas. Aparte de los comentarios propios, la utilidad javadoc nos proporciona una serie de etiquetas para completar la informacin que queremos dar de una determinada clase o mtodo. Son las siguientes: @author nombre (desde la versin 1.0 del JDK/SDK)http://www.javahispano.com Indica el autor de la clase en el argumento nombre. Un comentario de este tipo Castro Guia Reyes Romero
9
Proyecto Final de Programacin I puede tener ms de un autor en cuyo caso podemos usar tantas etiquetas de este tipo como autores hayan colaborado en la creacin del cdigo fuente o bien podemos ponerlos a todos en una sola etiqueta. En ste ltimo caso, JavaDoc inserta una (,) y un espacio entre los diferentes nombres. @deprecated comentario (desde la versin 1.0 del JDK/SDK) Aade un comentario indicando que este API no debera volver a usarse, aunque aun siga perteneciendo a la distribucin del SDK que estemos utilizando, por estar desautorizado o "desfasado". No obstante, sto es slo una advertencia que nosotros damos a los usuarios de nuestras API's, al igual que las distribuciones de Sun hacen con nosotros. Realmente, lo que estamos haciendo al decir que una determinada API est desfasada es prevenir de que en un futuro podrn surgir incompatibilidades si seguimos usndolas ya que ste es el paso a previo a la desaparicin del API en concreto. En la primera frase del comentario, que es la que la documentacin nos la muestra en la seccin del resumen de nuestra clase, deberamos como mnimo poner desde que versin de nuestra API est desautorizada y por quin se debera sustituir. A partir de Java 1.2 podemos usar {@link} para reverenciar por quin debemos hacer la sustitucin. @exception nombre-clase descripcin (desde la versin 1.0 del JDK/SDK).Esta etiqueta acta exactamente igual que @throws. Formato de los comentarios JavaDoc Los comentarios JavaDoc estn destinados a describir, principalmente, clases y mtodos. Como estn pensados para que otro programador los lea y utilice la clase (o mtodo) correspondiente, se decidi fijar al menos parcialmente un formato comn, de forma que los comentarios escritos por un programador resultaran legibles por otro. Para ello los comentarios JavaDoc deben incluir unos indicadores especiales, que comienzan siempre por '@' y se suelen colocar al comienzo de lnea. Por ejemplo esta es una clase para representar nmeros crculos (reducida al mnimo): package figuras; Castro Guia Reyes Romero
10
Proyecto Final de Programacin I /** * Una clase para representar crculos situados sobre el plano. * Cada crculo queda determinado por su radio junto con las * coordenadas de su centro. * @version 1.2, 24/12/04 * @author Rafa Caballero */ public class Crculo { protected double x,y; // coordenadas del centro protected double r; // radio del crculo /** * Crea un crculo a partir de su origen su radio. * @param x La coordenada x del centro del crculo. * @param y La coordenada y del centro del crculo. * @param r El radio del crculo. Debe ser mayor o igual a 0. */ public Circulo(double x, double y, double r) { this.x=x; this.y = y; this.r = r; } /** * Clculo del rea de este crculo. * @return El rea (mayor o igual que 0) del crculo. */ public double rea() { return Math.PI*r*r; } /** * Indica si un punto est dentro del crculo. * @param px componente x del punto * @param py componente y del punto * @return true si el punto est dentro del crculo o false en otro caso. Castro Guia Reyes Romero
11
Proyecto Final de Programacin I */ public boolean contiene(double px, double py) { /* Calculamos la distancia de (px,py) al centro del crculo (x,y), que se obtiene como raz cuadrada de (px-x)^2+(py-y)^2 */ double d = Math.sqrt((px-x)*(px-x)+(py-y)*(py-y)); // el crculo contiene el punto si d es menor o igual al radio return d <= r; } } Como se ve, y esto es usual en JavaDoc, la descripcin de la clase o del mtodo no va precedida de ningn indicador. Se usan indicadores para el nmero de versin (@version), el autor (@author) y otros. Es importante observar que los indicadores no son obligatorios; por ejemplo en un mtodo sin parmetros no se incluye obviamente el indicador @param. Tambin puede darse que un comentario incluya un indicador ms de una vez, por ejemplo varios indicadores @param porque el mtodo tiene varios parmetros.
5.- MARCO METODOLGICO Aqu se detallan todos los algoritmos que se disearon para obtener el programa final. Debe constar la opcin del men, el propsito y el diagrama de flujo de cada algoritmo. 5.1 Anlisis de resultados Presentar una prueba de escritorio de cada algoritmo. Colocar la prueba en formato de tablas. Numerar las tablas con su respectivo epgrafe. 5.2 Solucin El problema es la poca interactividad que hay entre la clase y el alumno es por esto que se desea implementar una manera diferente de ensear y aprender de una manera divertida y al mismo tiempo educativa.
12
13
14
15
6.- CONCLUSIONES Concluimos de nuestro objetivo general que por medio de este programa el cual es un juego educativo sobre la naturaleza, hemos puesto en practica todo lo aprendido de los conocimientos impartidos por nuestro docente, realizando asi una manera diferente de aprender tomando en cuentas las caracteristicas del alumno. Esta aplicacion servira para evaluar tanto al docente como al estudiante de una manera practica y sencilla a traves de recursos informaticos, dando a conocer las falencias del alumno y de esta forma el docente podra reforzar sus puntos fragiles. Mediante este programa tendremos una manera entretenida de evaluar al usuario, tomando en cuenta que asi aplicara sus conocimientos adquiridos en clases sobre la naturaleza. Obtener como resultado las diferentes formas de plasmar el aprendizaje no solo de manera escrita, verbal o mimica, sino tambien por medio de la tecnologia que en este caso seria el presente programa. Castro Guia Reyes Romero
16
Proyecto Final de Programacin I 7.- RECOMENDACIONES Se recomienda que antes de empezar a programar se tenga claro lo que se desea realizar, cual es objetivo que se quiere alcanzar y con que finalidad se va a crear el proyecto. Buscar los medios necesarios para realizar un programa con bases, investigar sobre le tema ha desarrollar para asi generar respuesta correctas. Saber los parametros de calificacion para evaluar correctamente al usuario dandole a conocer en que opciones tiene falencias. Motivar a quienes hagan uso del juego que experimenten el pder demostrar sus conocimientos d euna manera divertida y novedosa; en donde se realizara una fucion de sus conocimientos y la tecnologia. 9.- REFERENCIAS BIBLIOGRFICAS 10.- ANEXOS. 10.1.- Cdigo fuente del programa 10.1.1 Algoritmo Menu package juegodeponerpartes; public class Menu extends javax.swing.JFrame { public Menu() { initComponents(); } @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() { jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jButton1 = new javax.swing.JButton(); Castro Guia Reyes Romero
17
Proyecto Final de Programacin I jButton2 = new javax.swing.JButton(); jLabel4 = new javax.swing.JLabel(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); jLabel1.setFont(new java.awt.Font("Wide Latin", 0, 36)); // NOI18N jLabel1.setText("Bienvenidos"); jLabel2.setText("Hola amigito(a).. Quieres ingresar a nuestro juego. "); jButton1.setText("Aceptar"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); jButton2.setText("Salir"); jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton2ActionPerformed(evt); } }); jLabel4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/FondoMenu.jpg"))); // NOI18N javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() Castro Guia Reyes Romero
18
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN G) .addGroup(layout.createSequentialGroup() .addGap(28, 28, 28) .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 394, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup() .addGap(80, 80, 80) .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 290, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup() .addGap(120, 120, 120) .addComponent(jButton1) .addGap(59, 59, 59) .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGroup(layout.createSequentialGroup() .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(40, 40, 40) Castro Guia Reyes Romero
19
Proyecto Final de Programacin I .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(24, 24, 24) .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(42, 42, 42) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN G) .addComponent(jButton1) .addComponent(jButton2))) .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 250, javax.swing.GroupLayout.PREFERRED_SIZE) ); pack(); }// </editor-fold> private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: dispose(); } private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: Presentacion nuevo = new Presentacion(); nuevo.setVisible(true); this.setVisible(false); } /** * @param args the command line arguments */ public static void main(String args[]) { /* Set the Nimbus look and feel */ Castro Guia Reyes Romero
20
Proyecto Final de Programacin I //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(Menu.class.getName()).log(java.util.logging.Level. SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(Menu.class.getName()).log(java.util.logging.Level. SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(Menu.class.getName()).log(java.util.logging.Level. SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(Menu.class.getName()).log(java.util.logging.Level. SEVERE, null, ex); Castro Guia Reyes Romero
21
Proyecto Final de Programacin I } //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new Menu().setVisible(true); } }); } // Variables declaration - do not modify private javax.swing.JButton jButton1; private javax.swing.JButton jButton2; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel4; // End of variables declaration 10.1.2 Algortimo Presentacin package juegodeponerpartes; import javax.swing.*; public class Presentacion extends javax.swing.JFrame { public Presentacion() { initComponents(); } @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() { }
22
Proyecto Final de Programacin I jLabel1 = new javax.swing.JLabel(); jButton1 = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); jLabel1.setText("Espero que la pases bien y super divertido."); jButton1.setText("Aceptar"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN G) .addGroup(layout.createSequentialGroup() .addGap(139, 139, 139) .addComponent(jButton1)) .addGroup(layout.createSequentialGroup() .addGap(31, 31, 31) .addComponent(jLabel1, Castro Guia Reyes Romero
23
Proyecto Final de Programacin I javax.swing.GroupLayout.PREFERRED_SIZE, 266, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap(62, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(34, 34, 34) .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 51, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(jButton1) .addContainerGap(25, Short.MAX_VALUE)) ); pack(); }// </editor-fold> private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: submenudelJuego nuevo = new submenudelJuego(); nuevo.setVisible(true); this.setVisible(false); } /** * @param args the command line arguments */ Castro Guia Reyes Romero
24
Proyecto Final de Programacin I public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(Presentacion.class.getName()).log(java.util.loggin g.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { Castro Guia Reyes Romero
25
java.util.logging.Logger.getLogger(Presentacion.class.getName()).log(java.util.loggin g.Level.SEVERE, null, ex); } //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new Presentacion().setVisible(true); } }); } // Variables declaration - do not modify private javax.swing.JButton jButton1; private javax.swing.JLabel jLabel1; // End of variables declaration } 10.1.3 Algoritmo Sub Men package juegodeponerpartes; public class submenudelJuego extends javax.swing.JFrame { public submenudelJuego() { Castro Guia Reyes Romero
26
Proyecto Final de Programacin I initComponents(); } @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() { jTextField1 = new javax.swing.JTextField(); jTextField2 = new javax.swing.JTextField(); jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel(); jLabel4 = new javax.swing.JLabel(); jLabel6 = new javax.swing.JLabel(); jLabel5 = new javax.swing.JLabel(); jLabel7 = new javax.swing.JLabel(); jButton1 = new javax.swing.JButton(); jButton2 = new javax.swing.JButton(); jButton3 = new javax.swing.JButton(); jTextField1.setText("jTextField1"); jTextField2.setText("jTextField2"); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); jLabel1.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N jLabel1.setText("Escoje el juego que quieras..."); jLabel2.setText("Colocale las partes al Arbol"); jLabel3.setText("Colocar el nombre a los animales");
27
Proyecto Final de Programacin I jLabel4.setText("Coloca las partes a las celulas "); jLabel6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/iconoArbol.png"))); // NOI18N jLabel5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/inconoanimales.png"))); / / NOI18N jLabel7.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/iconocelula.png"))); // NOI18N jButton1.setText("Ir a "); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); jButton2.setText("Ir a"); jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton2ActionPerformed(evt); } }); jButton3.setText("Ir a"); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); Castro Guia Reyes Romero
28
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN G)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN G, false) .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, 198, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN G) .addComponent(jLabel6)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN G, false) .addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) Castro Guia Reyes Romero
29
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN G) .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(29, 29, 29)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 278, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(89, 89, 89)) ); layout.setVerticalGroup(
30
Proyecto Final de Programacin I layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(33, 33, 33) .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(26, 26, 26)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN G, false) .addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, 58, Short.MAX_VALUE) .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(9, 9, 9)))
Proyecto Final de Programacin I .addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, 59, Short.MAX_VALUE) .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) .addGroup(layout.createSequentialGroup() .addGap(35, 35, 35) .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN G, false) .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLabel7, javax.swing.GroupLayout.DEFAULT_SIZE, 57, Short.MAX_VALUE))) .addGroup(layout.createSequentialGroup() .addGap(28, 28, 28) .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 32, Castro Guia Reyes Romero
32
Proyecto Final de Programacin I javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap(27, Short.MAX_VALUE)) ); pack(); }// </editor-fold> private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: ArbolJuego nuevo = new ArbolJuego(); nuevo.setVisible(true); this.setVisible(false); } private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: JuegoDeNombreAnimales nuevo = new JuegoDeNombreAnimales(); nuevo.setVisible(true); this.setVisible(false); } /** * @param args the command line arguments */ public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
33
Proyecto Final de Programacin I /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) {
34
java.util.logging.Logger.getLogger(submenudelJuego.class.getName()).log(java.util.l ogging.Level.SEVERE, null, ex); } //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new submenudelJuego().setVisible(true); } }); } // Variables declaration - do not modify private javax.swing.JButton jButton1; private javax.swing.JButton jButton2; private javax.swing.JButton jButton3; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; private javax.swing.JLabel jLabel5; private javax.swing.JLabel jLabel6; private javax.swing.JLabel jLabel7; private javax.swing.JTextField jTextField1; private javax.swing.JTextField jTextField2; Castro Guia Reyes Romero
35
Proyecto Final de Programacin I // End of variables declaration } 10.1.4 Algoritmo Arbol Juego package juegodeponerpartes; import javax.swing.JOptionPane; import java.util.Random; //import java.util.HashSet; import java.awt.Color; public class ArbolJuego extends javax.swing.JFrame { int acu=0; int acu1=0; int acu2=0; int acu3=0; int acu4=0; public ArbolJuego() { initComponents(); int aletorio[]=new int [10]; int i=0,j; aletorio[i]=(int)(Math.random()*10); for(i=1;i<10;i++) { aletorio[i]=(int)(Math.random()*10); for(j=0;j<i;j++) { Castro Guia Reyes Romero
36
Proyecto Final de Programacin I if(aletorio[i]==aletorio[j]) { i--; } } } for(i=0;i<10;i++) { jLabel1.setText(Integer.toString(+aletorio[0])); JLabel2.setText(Integer.toString(+aletorio[1])); jLabel4.setText(Integer.toString(+aletorio[2])); jLabel5.setText(Integer.toString(+aletorio[3])); jLabel6.setText(Integer.toString(+aletorio[4]));
37
Proyecto Final de Programacin I error5.setVisible(false); error6.setVisible(false); error7.setVisible(false); error8.setVisible(false); error9.setVisible(false); error10.setVisible(false); } @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() {
Panel = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); JLabel2 = new javax.swing.JLabel(); txtmensajehojas = new javax.swing.JLabel(); txtmensajeraiz = new javax.swing.JLabel(); txtmensajeramas = new javax.swing.JLabel(); jLabel4 = new javax.swing.JLabel(); jLabel5 = new javax.swing.JLabel(); jLabel6 = new javax.swing.JLabel(); jLabel8 = new javax.swing.JLabel(); jLabel9 = new javax.swing.JLabel(); jLabel10 = new javax.swing.JLabel(); txtmensajeFruto = new javax.swing.JLabel();
38
Proyecto Final de Programacin I jLabel11 = new javax.swing.JLabel(); Txtmensaje = new javax.swing.JLabel(); jLabel12 = new javax.swing.JLabel(); TalloIng = new javax.swing.JTextField(); FrutoIng = new javax.swing.JTextField(); RaizIng = new javax.swing.JTextField(); HojasIng = new javax.swing.JTextField(); jLabel13 = new javax.swing.JLabel(); btnComparar = new javax.swing.JButton(); jButton8 = new javax.swing.JButton(); jLabel14 = new javax.swing.JLabel(); RamasIng1 = new javax.swing.JTextField(); AcpRamas = new javax.swing.JLabel(); error6 = new javax.swing.JLabel(); AcpFrt = new javax.swing.JLabel(); AcpRaiz = new javax.swing.JLabel(); AcpHojas = new javax.swing.JLabel(); AcpTallo = new javax.swing.JLabel(); error1 = new javax.swing.JLabel(); error7 = new javax.swing.JLabel(); error2 = new javax.swing.JLabel(); error8 = new javax.swing.JLabel(); error3 = new javax.swing.JLabel(); error9 = new javax.swing.JLabel();
39
Proyecto Final de Programacin I error4 = new javax.swing.JLabel(); error5 = new javax.swing.JLabel(); error10 = new javax.swing.JLabel(); jButton1 = new javax.swing.JButton(); btnAcepTallo = new javax.swing.JButton(); btnAcepFruto = new javax.swing.JButton(); btnAcepHojsh = new javax.swing.JButton(); btnAcepRamas = new javax.swing.JButton(); puntajeTotal = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
Panel.setLayout(null);
40
41
jLabel9.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N jLabel9.setText("Fruto"); Panel.add(jLabel9); jLabel9.setBounds(430, 120, 50, 30);
jLabel10.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N jLabel10.setText("Raiz"); Panel.add(jLabel10); jLabel10.setBounds(430, 160, 50, 30); txtmensajeFruto.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N Panel.add(txtmensajeFruto); txtmensajeFruto.setBounds(120, 70, 70, 30); jLabel11.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N jLabel11.setText("Hojas"); Panel.add(jLabel11); jLabel11.setBounds(430, 200, 60, 30); Txtmensaje.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N Panel.add(Txtmensaje); Txtmensaje.setBounds(170, 300, 50, 20); jLabel12.setText("Coloque el nmero correcto segun sus ubicaciones:");
42
Proyecto Final de Programacin I Panel.add(jLabel12); jLabel12.setBounds(360, 30, 290, 40); TalloIng.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { TalloIngActionPerformed(evt); } }); Panel.add(TalloIng); TalloIng.setBounds(500, 80, 90, 30); Panel.add(FrutoIng); FrutoIng.setBounds(500, 120, 90, 30); RaizIng.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { RaizIngActionPerformed(evt); } }); Panel.add(RaizIng); RaizIng.setBounds(500, 160, 90, 30); Panel.add(HojasIng); HojasIng.setBounds(500, 200, 90, 30); jLabel13.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/ARBOL.png"))); // NOI18N Panel.add(jLabel13); jLabel13.setBounds(10, 10, 412, 400); Castro Guia Reyes Romero
43
Proyecto Final de Programacin I btnComparar.setFont(new java.awt.Font("Aharoni", 1, 12)); // NOI18N btnComparar.setText("Comparar"); btnComparar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnCompararActionPerformed(evt); } }); Panel.add(btnComparar); btnComparar.setBounds(570, 300, 100, 23); jButton8.setFont(new java.awt.Font("Aharoni", 1, 12)); // NOI18N jButton8.setText("Regresar"); jButton8.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton8ActionPerformed(evt); } }); Panel.add(jButton8); jButton8.setBounds(440, 300, 100, 23); jLabel14.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N jLabel14.setText("Ramas"); Panel.add(jLabel14); jLabel14.setBounds(430, 240, 60, 30); Panel.add(RamasIng1); RamasIng1.setBounds(500, 240, 90, 30);
44
Proyecto Final de Programacin I AcpRamas.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/visto.png"))); // NOI18N Panel.add(AcpRamas); AcpRamas.setBounds(680, 240, 30, 30); error6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/incorrecto.png"))); // NOI18N Panel.add(error6); error6.setBounds(740, 80, 30, 30); AcpFrt.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/visto.png"))); // NOI18N Panel.add(AcpFrt); AcpFrt.setBounds(680, 120, 30, 30); AcpRaiz.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/visto.png"))); // NOI18N Panel.add(AcpRaiz); AcpRaiz.setBounds(680, 160, 30, 30); AcpHojas.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/visto.png"))); // NOI18N Panel.add(AcpHojas); AcpHojas.setBounds(680, 200, 30, 30); AcpTallo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/visto.png"))); // NOI18N Panel.add(AcpTallo); AcpTallo.setBounds(680, 80, 30, 30); error1.setIcon(new Castro Guia Reyes Romero
45
Proyecto Final de Programacin I javax.swing.ImageIcon(getClass().getResource("/Imagenes/incorrecto.png"))); // NOI18N Panel.add(error1); error1.setBounds(710, 80, 30, 30); error7.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/incorrecto.png"))); // NOI18N Panel.add(error7); error7.setBounds(740, 120, 30, 30); error2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/incorrecto.png"))); // NOI18N Panel.add(error2); error2.setBounds(710, 120, 30, 30); error8.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/incorrecto.png"))); // NOI18N Panel.add(error8); error8.setBounds(740, 160, 30, 30); error3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/incorrecto.png"))); // NOI18N Panel.add(error3); error3.setBounds(710, 160, 30, 30); error9.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/incorrecto.png"))); // NOI18N Castro Guia Reyes Romero
46
Proyecto Final de Programacin I Panel.add(error9); error9.setBounds(740, 200, 30, 30); error4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/incorrecto.png"))); // NOI18N Panel.add(error4); error4.setBounds(710, 200, 30, 30); error5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/incorrecto.png"))); // NOI18N Panel.add(error5); error5.setBounds(710, 240, 30, 30); error10.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/incorrecto.png"))); // NOI18N Panel.add(error10); error10.setBounds(740, 240, 30, 30); jButton1.setText("Aceptar"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); Panel.add(jButton1); jButton1.setBounds(600, 160, 70, 23);
47
Proyecto Final de Programacin I btnAcepTallo.setText("Aceptar"); btnAcepTallo.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnAcepTalloActionPerformed(evt); } }); Panel.add(btnAcepTallo); btnAcepTallo.setBounds(600, 80, 71, 23); btnAcepFruto.setText("Aceptar"); btnAcepFruto.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnAcepFrutoActionPerformed(evt); } }); Panel.add(btnAcepFruto); btnAcepFruto.setBounds(600, 120, 71, 23); btnAcepHojsh.setText("Aceptar"); btnAcepHojsh.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnAcepHojshActionPerformed(evt); } }); Panel.add(btnAcepHojsh); btnAcepHojsh.setBounds(600, 200, 71, 23);
48
Proyecto Final de Programacin I btnAcepRamas.setText("Aceptar"); btnAcepRamas.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnAcepRamasActionPerformed(evt); } }); Panel.add(btnAcepRamas); btnAcepRamas.setBounds(600, 240, 71, 23); Panel.add(puntajeTotal); puntajeTotal.setBounds(420, 370, 330, 60); jLabel3.setText("P u n t a j e"); Panel.add(jLabel3); jLabel3.setBounds(440, 344, 110, 20); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(Panel, javax.swing.GroupLayout.DEFAULT_SIZE, 817, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(Panel, javax.swing.GroupLayout.DEFAULT_SIZE, 471, Short.MAX_VALUE) Castro Guia Reyes Romero
49
Proyecto Final de Programacin I ); pack(); }// </editor-fold> private void TalloIngActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: } private void btnCompararActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: } private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: submenudelJuego nuevo = new submenudelJuego (); nuevo.setVisible(true); this.setVisible(false); } private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: Color colorMensaje=new Color(9,53,140); if (jLabel1.getText().equals(RaizIng.getText())) { txtmensajeraiz.setText("Raiz"); RaizIng.setEnabled(false); txtmensajeraiz.setForeground(colorMensaje); AcpRaiz.setVisible(true);
50
Proyecto Final de Programacin I } else { RaizIng.setText(""); acu2=acu2+1; if (acu2==1) error3.setVisible(true); else if (acu2==2) error8.setVisible(true); else if (acu2==3) RaizIng.setEnabled(false); JOptionPane.showMessageDialog(this, "Lo siento amigo, tu respuesta " + "es incorecta"); } } private void RaizIngActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: } private void btnAcepTalloActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: Color colorMensaje=new Color(9,53,140);
51
Proyecto Final de Programacin I if (JLabel2.getText().equals(TalloIng.getText())) { Txtmensaje.setText("Tallo"); TalloIng.setEnabled(false); Txtmensaje.setForeground(colorMensaje); AcpTallo.setVisible(true); } else { TalloIng.setText(""); acu=acu+1; if (acu==1) error1.setVisible(true); else if (acu==2) error6.setVisible(true); else if (acu==3) TalloIng.setEnabled(false); JOptionPane.showMessageDialog(this, "Lo siento amigo, tu respuesta " + "es incorecta"); } } private void btnAcepFrutoActionPerformed(java.awt.event.ActionEvent evt) {
52
Proyecto Final de Programacin I // TODO add your handling code here: Color colorMensaje=new Color(9,53,140); if (jLabel5.getText().equals(FrutoIng.getText())) { txtmensajeFruto.setText("Fruto"); FrutoIng.setEnabled(false); txtmensajeFruto.setForeground(colorMensaje); AcpFrt.setVisible(true); } else {
FrutoIng.setText(""); acu1=acu1+1; if (acu1==1) error2.setVisible(true); else if (acu1==2) error7.setVisible(true); else if (acu1==3) FrutoIng.setEnabled(false); JOptionPane.showMessageDialog(this, "Lo siento amigo, tu respuesta " + "es incorecta"); } }
53
private void btnAcepHojshActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: Color colorMensaje=new Color(9,53,140); if (jLabel6.getText().equals(HojasIng.getText())) { txtmensajehojas.setText("Raiz"); HojasIng.setEnabled(false); txtmensajehojas.setForeground(colorMensaje); AcpHojas.setVisible(true); } else { HojasIng.setText(""); acu3=acu3+1; if (acu3==1) error4.setVisible(true); else if (acu3==2) error9.setVisible(true); else if (acu3==3) HojasIng.setEnabled(false); JOptionPane.showMessageDialog(this, "Lo siento amigo, tu respuesta "
54
Proyecto Final de Programacin I + "es incorecta"); } } private void btnAcepRamasActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: Color colorMensaje=new Color(9,53,140);
if (jLabel4.getText().equals(RamasIng1.getText())) { txtmensajeramas.setText("Raiz"); RamasIng1.setEnabled(false); txtmensajeramas.setForeground(colorMensaje); AcpRamas.setVisible(true); } else { RamasIng1.setText(""); acu4=acu4+1; if (acu4==1) error5.setVisible(true); else if (acu4==2) error10.setVisible(true); else
55
Proyecto Final de Programacin I if (acu4==3) RamasIng1.setEnabled(false); JOptionPane.showMessageDialog(this, "Lo siento amigo, tu respuesta " + "es incorecta"); } } /** * @param args the command line arguments */ public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } Castro Guia Reyes Romero
56
/* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new ArbolJuego().setVisible(true); } }); Castro Guia Reyes Romero
57
Proyecto Final de Programacin I } // Variables declaration - do not modify private javax.swing.JLabel AcpFrt; private javax.swing.JLabel AcpHojas; private javax.swing.JLabel AcpRaiz; private javax.swing.JLabel AcpRamas; private javax.swing.JLabel AcpTallo; private javax.swing.JTextField FrutoIng; private javax.swing.JTextField HojasIng; private javax.swing.JLabel JLabel2; private javax.swing.JPanel Panel; private javax.swing.JTextField RaizIng; private javax.swing.JTextField RamasIng1; private javax.swing.JTextField TalloIng; private javax.swing.JLabel Txtmensaje; private javax.swing.JButton btnAcepFruto; private javax.swing.JButton btnAcepHojsh; private javax.swing.JButton btnAcepRamas; private javax.swing.JButton btnAcepTallo; private javax.swing.JButton btnComparar; private javax.swing.JLabel error1; private javax.swing.JLabel error10; private javax.swing.JLabel error2; private javax.swing.JLabel error3;
58
Proyecto Final de Programacin I private javax.swing.JLabel error4; private javax.swing.JLabel error5; private javax.swing.JLabel error6; private javax.swing.JLabel error7; private javax.swing.JLabel error8; private javax.swing.JLabel error9; private javax.swing.JButton jButton1; private javax.swing.JButton jButton8; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel10; private javax.swing.JLabel jLabel11; private javax.swing.JLabel jLabel12; private javax.swing.JLabel jLabel13; private javax.swing.JLabel jLabel14; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; private javax.swing.JLabel jLabel5; private javax.swing.JLabel jLabel6; private javax.swing.JLabel jLabel8; private javax.swing.JLabel jLabel9; private javax.swing.JLabel puntajeTotal; private javax.swing.JLabel txtmensajeFruto; private javax.swing.JLabel txtmensajehojas; private javax.swing.JLabel txtmensajeraiz;
59
Proyecto Final de Programacin I private javax.swing.JLabel txtmensajeramas; // End of variables declaration } 10.1.5 Juego de Nombres de Animales package juegodeponerpartes; public class JuegoDeNombreAnimales extends javax.swing.JFrame { public JuegoDeNombreAnimales() { initComponents(); } @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() {
jButton1 = new javax.swing.JButton(); jButton2 = new javax.swing.JButton(); jButton3 = new javax.swing.JButton(); jLabel1 = new javax.swing.JLabel(); jButton4 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); jButton1.setText("Mamiferos"); jButton2.setText("Hervivoros"); jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { Castro Guia Reyes Romero
60
Proyecto Final de Programacin I jButton2ActionPerformed(evt); } }); jButton3.setText("Carnivoros"); jLabel1.setText("Los animales se clasifican en:"); jButton4.setText("Atras"); jButton4.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton4ActionPerformed(evt); } });
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(66, 66, 66) .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 133, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(25, 25, 25) .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 133, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(39, 39, 39) Castro Guia Reyes Romero
61
Proyecto Final de Programacin I .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 133, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(47, Short.MAX_VALUE)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN G) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 192, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(182, 182, 182)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addComponent(jButton4) .addGap(251, 251, 251)))) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(53, 53, 53) .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE,
62
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELIN E) .addComponent(jButton3) .addComponent(jButton1) .addComponent(jButton2)) .addGap(40, 40, 40) .addComponent(jButton4) .addContainerGap(71, Short.MAX_VALUE)) );
pack(); }// </editor-fold> private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: GrupoHervivoros nuevo = new GrupoHervivoros(); nuevo.setVisible(true); this.setVisible(false); }
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: submenudelJuego nuevo = new submenudelJuego(); Castro Guia Reyes Romero
63
/** * @param args the command line arguments */ public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { Castro Guia Reyes Romero
64
java.util.logging.Logger.getLogger(JuegoDeNombreAnimales.class.getName()).log(ja va.util.logging.Level.SEVERE, null, ex); } //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new JuegoDeNombreAnimales().setVisible(true); } }); } // Variables declaration - do not modify private javax.swing.JButton jButton1; Castro Guia Reyes Romero
65
Proyecto Final de Programacin I private javax.swing.JButton jButton2; private javax.swing.JButton jButton3; private javax.swing.JButton jButton4; private javax.swing.JLabel jLabel1; // End of variables declaration } 10.1.6 Algoritmo Grupo Hervivoros package juegodeponerpartes; import java.awt.Color; import javax.swing.JOptionPane; public class GrupoHervivoros extends javax.swing.JFrame { public GrupoHervivoros() { initComponents(); } @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() { jPanel1 = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); ingrVaca = new javax.swing.JTextField(); jButton1 = new javax.swing.JButton(); jButton2 = new javax.swing.JButton(); jButton3 = new javax.swing.JButton(); Castro Guia Reyes Romero
66
Proyecto Final de Programacin I setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); jPanel1.setLayout(null); jLabel1.setText("Identifica este animal:"); jPanel1.add(jLabel1); jLabel1.setBounds(30, 30, 120, 30); jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Vaquita.png"))); // NOI18N jPanel1.add(jLabel2); jLabel2.setBounds(130, 50, 210, 230); ingrVaca.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { ingrVacaActionPerformed(evt); } }); jPanel1.add(ingrVaca); ingrVaca.setBounds(80, 280, 110, 30); jButton1.setText("Aceptar"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); jPanel1.add(jButton1); jButton1.setBounds(100, 320, 71, 23); Castro Guia Reyes Romero
67
Proyecto Final de Programacin I jButton2.setText("Siguiente"); jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton2ActionPerformed(evt); } }); jPanel1.add(jButton2); jButton2.setBounds(290, 280, 80, 23); jButton3.setText("Atras"); jButton3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton3ActionPerformed(evt); } }); jPanel1.add(jButton3); jButton3.setBounds(290, 320, 80, 23); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 475, Short.MAX_VALUE) ); layout.setVerticalGroup( Castro Guia Reyes Romero
68
Proyecto Final de Programacin I layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 372, Short.MAX_VALUE) ); pack(); }// </editor-fold> private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: String vacaIngresado=ingrVaca.getText(); { if (vacaIngresado.equals("Vaca")||vacaIngresado.equals("vaca")|| vacaIngresado.equals("VACA")) { JOptionPane.showMessageDialog(this,"La VACA es un animal mamfero,\n" + "nace vivo del vientre de la madre.\n" + "Es tambin vertebrado porque tiene huesos\n" + "y herbvoro porque se\n" + "alimenta de hierba y pastos."); ingrVaca.enable(false); } else { ingrVaca.setText(""); ingrVaca.enable(false); JOptionPane.showMessageDialog(this, "Lo siento amigo, prueva con el " Castro Guia Reyes Romero
69
Proyecto Final de Programacin I + "siguiente animal :)"); } } } private void ingrVacaActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: } private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: GrupoHervivoros2 nuevo = new GrupoHervivoros2(); nuevo.setVisible(true); this.setVisible(false); } private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: JuegoDeNombreAnimales nuevo = new JuegoDeNombreAnimales(); nuevo.setVisible(true); this.setVisible(false); } /** * @param args the command line arguments */ public static void main(String args[]) { /* Set the Nimbus look and feel */
70
Proyecto Final de Programacin I //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(GrupoHervivoros.class.getName()).log(java.util.log
71
java.util.logging.Logger.getLogger(GrupoHervivoros.class.getName()).log(java.util.log ging.Level.SEVERE, null, ex); } //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new GrupoHervivoros().setVisible(true); } }); } // Variables declaration - do not modify private javax.swing.JTextField ingrVaca; private javax.swing.JButton jButton1; private javax.swing.JButton jButton2; private javax.swing.JButton jButton3; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JPanel jPanel1; // End of variables declaration }
72
Proyecto Final de Programacin I 10.1.7 Algoritmo Grupo Hervivoros 2 package juegodeponerpartes; import javax.swing.JOptionPane; public class GrupoHervivoros2 extends javax.swing.JFrame { public GrupoHervivoros2() { initComponents(); } @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() { jPanel1 = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); ingrElefante = new javax.swing.JTextField(); jButton1 = new javax.swing.JButton(); jButton2 = new javax.swing.JButton(); jButton3 = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); jPanel1.setLayout(null); jLabel1.setText("Identifica este animal:"); jPanel1.add(jLabel1); jLabel1.setBounds(30, 30, 120, 30); jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/elefantitu.png"))); // NOI18N Castro Guia Reyes Romero
73
Proyecto Final de Programacin I jPanel1.add(jLabel2); jLabel2.setBounds(130, 50, 210, 230); ingrElefante.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { ingrElefanteActionPerformed(evt); } }); jPanel1.add(ingrElefante); ingrElefante.setBounds(80, 280, 110, 30);
jButton1.setText("Aceptar"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); jPanel1.add(jButton1); jButton1.setBounds(100, 320, 71, 23); jButton2.setText("Siguiente"); jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton2ActionPerformed(evt); } });
74
Proyecto Final de Programacin I jPanel1.add(jButton2); jButton2.setBounds(290, 280, 80, 23); jButton3.setText("Menu"); jButton3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton3ActionPerformed(evt); } }); jPanel1.add(jButton3); jButton3.setBounds(290, 320, 80, 23); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 480, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 380, Short.MAX_VALUE) );
Proyecto Final de Programacin I }// </editor-fold> private void ingrElefanteActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: } private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: String elefanteIngresado=ingrElefante.getText(); { if (elefanteIngresado.equals("Elefante")|| elefanteIngresado.equals("elefante")||elefanteIngresado.equals("ELEFANTE")) { JOptionPane.showMessageDialog(this,"Es el animal terrestre ms grande del mundo,\n " +"a los elefante los podemos identificar por sus gigantes\n" +"orejas, estos animales comen races, frutas,\n" +"cortezas y todo tipo de cosas relacionadas.\n" +"Pueden llegar a comer unos 136 kilogramos al da de comida.\n"); ingrElefante.enable(false); } else { ingrElefante.setText(""); ingrElefante.enable(false); Castro Guia Reyes Romero
76
Proyecto Final de Programacin I JOptionPane.showMessageDialog(this, "Lo siento amigo, prueva con el " + "siguiente animal :)"); } } } private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: JuegoDeNombreAnimales nuevo = new JuegoDeNombreAnimales(); nuevo.setVisible(true); this.setVisible(false); } private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: GrupoHervivoros2 nuevo = new GrupoHervivoros2(); nuevo.setVisible(true); this.setVisible(false); } /** * @param args the command line arguments */ public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
77
Proyecto Final de Programacin I /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) {
78
java.util.logging.Logger.getLogger(GrupoHervivoros2.class.getName()).log(java.util.lo gging.Level.SEVERE, null, ex); } //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new GrupoHervivoros2().setVisible(true); } }); } // Variables declaration - do not modify private javax.swing.JTextField ingrElefante; private javax.swing.JButton jButton1; private javax.swing.JButton jButton2; private javax.swing.JButton jButton3; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JPanel jPanel1; // End of variables declaration }
79
80
81
Figura 13: Codigo Fuente Del Menu Figura 12: Codigo Fuente del Menu
82
83
84
85
Figura 19: Codigo Fuente del Juego de Colocas Las Partes Del Arbol
Figura 20: Codigo del Juego de Colocar Las Partes del Arbol
86
Proyecto Final de Programacin I MANUAL DEL PROGRAMADOR Algoritmo Menu package juegodeponerpartes; public class Menu extends javax.swing.JFrame { public Menu() { initComponents(); } @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() { jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jButton1 = new javax.swing.JButton(); jButton2 = new javax.swing.JButton(); jLabel4 = new javax.swing.JLabel(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); jLabel1.setFont(new java.awt.Font("Wide Latin", 0, 36)); // NOI18N jLabel1.setText("Bienvenidos"); jLabel2.setText("Hola amigito(a).. Quieres ingresar a nuestro juego. "); jButton1.setText("Aceptar"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); jButton2.setText("Salir");
87
Proyecto Final de Programacin I jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton2ActionPerformed(evt); } }); jLabel4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/FondoMenu.jpg"))); // NOI18N javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN G) .addGroup(layout.createSequentialGroup() .addGap(28, 28, 28) .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 394, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup() .addGap(80, 80, 80) .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 290, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup() .addGap(120, 120, 120) .addComponent(jButton1) .addGap(59, 59, 59) Castro Guia Reyes Romero
88
Proyecto Final de Programacin I .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGroup(layout.createSequentialGroup() .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(40, 40, 40) .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(24, 24, 24) .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(42, 42, 42) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN G) .addComponent(jButton1) .addComponent(jButton2))) .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 250, javax.swing.GroupLayout.PREFERRED_SIZE) ); pack(); }// </editor-fold> private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) { Castro Guia Reyes Romero
89
Proyecto Final de Programacin I // TODO add your handling code here: dispose(); } private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: Presentacion nuevo = new Presentacion(); nuevo.setVisible(true); this.setVisible(false); } /** * @param args the command line arguments */ public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) {
90
Proyecto Final de Programacin I java.util.logging.Logger.getLogger(Menu.class.getName()).log(java.util.logging.Level. SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(Menu.class.getName()).log(java.util.logging.Level. SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(Menu.class.getName()).log(java.util.logging.Level. SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(Menu.class.getName()).log(java.util.logging.Level. SEVERE, null, ex); } //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new Menu().setVisible(true); } }); } // Variables declaration - do not modify private javax.swing.JButton jButton1; private javax.swing.JButton jButton2; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel4; // End of variables declaration Castro Guia Reyes Romero }
91
Proyecto Final de Programacin I 10.1.2 Algortimo Presentacin package juegodeponerpartes; import javax.swing.*; public class Presentacion extends javax.swing.JFrame { public Presentacion() { initComponents(); } @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() { jLabel1 = new javax.swing.JLabel(); jButton1 = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); jLabel1.setText("Espero que la pases bien y super divertido."); jButton1.setText("Aceptar"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup(
92
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN G) .addGroup(layout.createSequentialGroup() .addGap(139, 139, 139) .addComponent(jButton1)) .addGroup(layout.createSequentialGroup() .addGap(31, 31, 31) .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 266, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap(62, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(34, 34, 34) .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 51, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(jButton1) .addContainerGap(25, Short.MAX_VALUE)) );
93
Proyecto Final de Programacin I pack(); }// </editor-fold> private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: submenudelJuego nuevo = new submenudelJuego(); nuevo.setVisible(true); this.setVisible(false); } /** * @param args the command line arguments */ public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); Castro Guia Reyes Romero
94
java.util.logging.Logger.getLogger(Presentacion.class.getName()).log(java.util.loggin g.Level.SEVERE, null, ex); } //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new Presentacion().setVisible(true); } Castro Guia Reyes Romero
95
Proyecto Final de Programacin I }); } // Variables declaration - do not modify private javax.swing.JButton jButton1; private javax.swing.JLabel jLabel1; // End of variables declaration } 10.1.3 Algoritmo Sub Men package juegodeponerpartes; public class submenudelJuego extends javax.swing.JFrame { public submenudelJuego() { initComponents(); } @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() { jTextField1 = new javax.swing.JTextField(); jTextField2 = new javax.swing.JTextField(); jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel(); jLabel4 = new javax.swing.JLabel(); jLabel6 = new javax.swing.JLabel(); jLabel5 = new javax.swing.JLabel(); Castro Guia Reyes Romero
96
Proyecto Final de Programacin I jLabel7 = new javax.swing.JLabel(); jButton1 = new javax.swing.JButton(); jButton2 = new javax.swing.JButton(); jButton3 = new javax.swing.JButton(); jTextField1.setText("jTextField1"); jTextField2.setText("jTextField2"); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); jLabel1.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N jLabel1.setText("Escoje el juego que quieras..."); jLabel2.setText("Colocale las partes al Arbol"); jLabel3.setText("Colocar el nombre a los animales"); jLabel4.setText("Coloca las partes a las celulas "); jLabel6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/iconoArbol.png"))); // NOI18N jLabel5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/inconoanimales.png"))); / / NOI18N jLabel7.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/iconocelula.png"))); // NOI18N jButton1.setText("Ir a "); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt);
97
Proyecto Final de Programacin I } }); jButton2.setText("Ir a"); jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton2ActionPerformed(evt); } }); jButton3.setText("Ir a"); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(42, 42, 42)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN G)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN G, false) .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) Castro Guia Reyes Romero
98
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN G) .addComponent(jLabel6)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN G, false) .addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLabel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN G) .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton3, Castro Guia Reyes Romero
99
Proyecto Final de Programacin I javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(29, 29, 29)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 278, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(89, 89, 89)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(33, 33, 33) .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(26, 26, 26)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN G, false) .addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, 58, Short.MAX_VALUE) .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
100
Proyecto Final de Programacin I layout.createSequentialGroup() .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(9, 9, 9)))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN G, false) .addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, 59, Short.MAX_VALUE) .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) .addGroup(layout.createSequentialGroup() .addGap(35, 35, 35) .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)))
101
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN G, false) .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLabel7, javax.swing.GroupLayout.DEFAULT_SIZE, 57, Short.MAX_VALUE))) .addGroup(layout.createSequentialGroup() .addGap(28, 28, 28) .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap(27, Short.MAX_VALUE)) ); pack(); }// </editor-fold> private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: ArbolJuego nuevo = new ArbolJuego(); nuevo.setVisible(true); this.setVisible(false); } private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: Castro Guia Reyes Romero
102
Proyecto Final de Programacin I JuegoDeNombreAnimales nuevo = new JuegoDeNombreAnimales(); nuevo.setVisible(true); this.setVisible(false); } /** * @param args the command line arguments */ public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { Castro Guia Reyes Romero
103
java.util.logging.Logger.getLogger(submenudelJuego.class.getName()).log(java.util.l ogging.Level.SEVERE, null, ex); } //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new submenudelJuego().setVisible(true); } }); } // Variables declaration - do not modify private javax.swing.JButton jButton1; Castro Guia Reyes Romero
104
Proyecto Final de Programacin I private javax.swing.JButton jButton2; private javax.swing.JButton jButton3; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; private javax.swing.JLabel jLabel5; private javax.swing.JLabel jLabel6; private javax.swing.JLabel jLabel7; private javax.swing.JTextField jTextField1; private javax.swing.JTextField jTextField2; // End of variables declaration } Algoritmo Arbol Juego package juegodeponerpartes; import javax.swing.JOptionPane; import java.util.Random; //import java.util.HashSet; import java.awt.Color; public class ArbolJuego extends javax.swing.JFrame { int acu=0; int acu1=0; int acu2=0; int acu3=0; int acu4=0; Castro Guia Reyes Romero
105
Proyecto Final de Programacin I public ArbolJuego() { initComponents(); int aletorio[]=new int [10]; int i=0,j; aletorio[i]=(int)(Math.random()*10); for(i=1;i<10;i++) { aletorio[i]=(int)(Math.random()*10); for(j=0;j<i;j++) { if(aletorio[i]==aletorio[j]) { i--; } } } for(i=0;i<10;i++) { jLabel1.setText(Integer.toString(+aletorio[0])); JLabel2.setText(Integer.toString(+aletorio[1])); jLabel4.setText(Integer.toString(+aletorio[2])); jLabel5.setText(Integer.toString(+aletorio[3])); jLabel6.setText(Integer.toString(+aletorio[4]));
106
Proyecto Final de Programacin I } AcpRaiz.setVisible(false); AcpTallo.setVisible(false); AcpRamas.setVisible(false); AcpFrt.setVisible(false); AcpHojas.setVisible(false); error1.setVisible(false); error2.setVisible(false); error3.setVisible(false); error4.setVisible(false); error5.setVisible(false); error6.setVisible(false); error7.setVisible(false); error8.setVisible(false); error9.setVisible(false); error10.setVisible(false); } @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() {
107
Proyecto Final de Programacin I txtmensajehojas = new javax.swing.JLabel(); txtmensajeraiz = new javax.swing.JLabel(); txtmensajeramas = new javax.swing.JLabel(); jLabel4 = new javax.swing.JLabel(); jLabel5 = new javax.swing.JLabel(); jLabel6 = new javax.swing.JLabel(); jLabel8 = new javax.swing.JLabel(); jLabel9 = new javax.swing.JLabel(); jLabel10 = new javax.swing.JLabel(); txtmensajeFruto = new javax.swing.JLabel(); jLabel11 = new javax.swing.JLabel(); Txtmensaje = new javax.swing.JLabel(); jLabel12 = new javax.swing.JLabel(); TalloIng = new javax.swing.JTextField(); FrutoIng = new javax.swing.JTextField(); RaizIng = new javax.swing.JTextField(); HojasIng = new javax.swing.JTextField(); jLabel13 = new javax.swing.JLabel(); btnComparar = new javax.swing.JButton(); jButton8 = new javax.swing.JButton(); jLabel14 = new javax.swing.JLabel(); RamasIng1 = new javax.swing.JTextField(); AcpRamas = new javax.swing.JLabel(); error6 = new javax.swing.JLabel();
108
Proyecto Final de Programacin I AcpFrt = new javax.swing.JLabel(); AcpRaiz = new javax.swing.JLabel(); AcpHojas = new javax.swing.JLabel(); AcpTallo = new javax.swing.JLabel(); error1 = new javax.swing.JLabel(); error7 = new javax.swing.JLabel(); error2 = new javax.swing.JLabel(); error8 = new javax.swing.JLabel(); error3 = new javax.swing.JLabel(); error9 = new javax.swing.JLabel(); error4 = new javax.swing.JLabel(); error5 = new javax.swing.JLabel(); error10 = new javax.swing.JLabel(); jButton1 = new javax.swing.JButton(); btnAcepTallo = new javax.swing.JButton(); btnAcepFruto = new javax.swing.JButton(); btnAcepHojsh = new javax.swing.JButton(); btnAcepRamas = new javax.swing.JButton(); puntajeTotal = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); Panel.setLayout(null); jLabel1.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N Panel.add(jLabel1);
109
Proyecto Final de Programacin I jLabel1.setBounds(230, 370, 34, 14); JLabel2.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N Panel.add(JLabel2); JLabel2.setBounds(160, 330, 34, 14); txtmensajehojas.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N Panel.add(txtmensajehojas); txtmensajehojas.setBounds(260, 70, 50, 20); txtmensajeraiz.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N Panel.add(txtmensajeraiz); txtmensajeraiz.setBounds(220, 340, 70, 20); txtmensajeramas.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N Panel.add(txtmensajeramas); txtmensajeramas.setBounds(260, 170, 70, 20); jLabel4.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N Panel.add(jLabel4); jLabel4.setBounds(250, 190, 34, 14); jLabel5.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N Panel.add(jLabel5); jLabel5.setBounds(140, 104, 34, 20); jLabel6.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N Panel.add(jLabel6); jLabel6.setBounds(260, 100, 40, 30); jLabel8.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N jLabel8.setText("Tallo");
110
Proyecto Final de Programacin I Panel.add(jLabel8); jLabel8.setBounds(430, 80, 50, 30); jLabel9.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N jLabel9.setText("Fruto"); Panel.add(jLabel9); jLabel9.setBounds(430, 120, 50, 30);
jLabel10.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N jLabel10.setText("Raiz"); Panel.add(jLabel10); jLabel10.setBounds(430, 160, 50, 30); txtmensajeFruto.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N Panel.add(txtmensajeFruto); txtmensajeFruto.setBounds(120, 70, 70, 30); jLabel11.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N jLabel11.setText("Hojas"); Panel.add(jLabel11); jLabel11.setBounds(430, 200, 60, 30); Txtmensaje.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N Panel.add(Txtmensaje); Txtmensaje.setBounds(170, 300, 50, 20); jLabel12.setText("Coloque el nmero correcto segun sus ubicaciones:"); Panel.add(jLabel12); jLabel12.setBounds(360, 30, 290, 40);
111
Proyecto Final de Programacin I TalloIng.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { TalloIngActionPerformed(evt); } }); Panel.add(TalloIng); TalloIng.setBounds(500, 80, 90, 30); Panel.add(FrutoIng); FrutoIng.setBounds(500, 120, 90, 30); RaizIng.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { RaizIngActionPerformed(evt); } }); Panel.add(RaizIng); RaizIng.setBounds(500, 160, 90, 30); Panel.add(HojasIng); HojasIng.setBounds(500, 200, 90, 30); jLabel13.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/ARBOL.png"))); // NOI18N Panel.add(jLabel13); jLabel13.setBounds(10, 10, 412, 400); btnComparar.setFont(new java.awt.Font("Aharoni", 1, 12)); // NOI18N btnComparar.setText("Comparar"); Castro Guia Reyes Romero
112
Proyecto Final de Programacin I btnComparar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnCompararActionPerformed(evt); } }); Panel.add(btnComparar); btnComparar.setBounds(570, 300, 100, 23); jButton8.setFont(new java.awt.Font("Aharoni", 1, 12)); // NOI18N jButton8.setText("Regresar"); jButton8.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton8ActionPerformed(evt); } }); Panel.add(jButton8); jButton8.setBounds(440, 300, 100, 23); jLabel14.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N jLabel14.setText("Ramas"); Panel.add(jLabel14); jLabel14.setBounds(430, 240, 60, 30); Panel.add(RamasIng1); RamasIng1.setBounds(500, 240, 90, 30); AcpRamas.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/visto.png"))); // NOI18N
113
Proyecto Final de Programacin I Panel.add(AcpRamas); AcpRamas.setBounds(680, 240, 30, 30); error6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/incorrecto.png"))); // NOI18N Panel.add(error6); error6.setBounds(740, 80, 30, 30); AcpFrt.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/visto.png"))); // NOI18N Panel.add(AcpFrt); AcpFrt.setBounds(680, 120, 30, 30); AcpRaiz.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/visto.png"))); // NOI18N Panel.add(AcpRaiz); AcpRaiz.setBounds(680, 160, 30, 30); AcpHojas.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/visto.png"))); // NOI18N Panel.add(AcpHojas); AcpHojas.setBounds(680, 200, 30, 30); AcpTallo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/visto.png"))); // NOI18N Panel.add(AcpTallo); AcpTallo.setBounds(680, 80, 30, 30); error1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/incorrecto.png"))); // NOI18N Castro Guia Reyes Romero
114
Proyecto Final de Programacin I Panel.add(error1); error1.setBounds(710, 80, 30, 30); error7.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/incorrecto.png"))); // NOI18N Panel.add(error7); error7.setBounds(740, 120, 30, 30); error2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/incorrecto.png"))); // NOI18N Panel.add(error2); error2.setBounds(710, 120, 30, 30); error8.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/incorrecto.png"))); // NOI18N Panel.add(error8); error8.setBounds(740, 160, 30, 30); error3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/incorrecto.png"))); // NOI18N Panel.add(error3); error3.setBounds(710, 160, 30, 30); error9.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/incorrecto.png"))); // NOI18N Panel.add(error9);
115
Proyecto Final de Programacin I error9.setBounds(740, 200, 30, 30); error4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/incorrecto.png"))); // NOI18N Panel.add(error4); error4.setBounds(710, 200, 30, 30); error5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/incorrecto.png"))); // NOI18N Panel.add(error5); error5.setBounds(710, 240, 30, 30); error10.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/incorrecto.png"))); // NOI18N Panel.add(error10); error10.setBounds(740, 240, 30, 30); jButton1.setText("Aceptar"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); Panel.add(jButton1); jButton1.setBounds(600, 160, 70, 23); btnAcepTallo.setText("Aceptar");
116
Proyecto Final de Programacin I btnAcepTallo.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnAcepTalloActionPerformed(evt); } }); Panel.add(btnAcepTallo); btnAcepTallo.setBounds(600, 80, 71, 23); btnAcepFruto.setText("Aceptar"); btnAcepFruto.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnAcepFrutoActionPerformed(evt); } }); Panel.add(btnAcepFruto); btnAcepFruto.setBounds(600, 120, 71, 23); btnAcepHojsh.setText("Aceptar"); btnAcepHojsh.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnAcepHojshActionPerformed(evt); } }); Panel.add(btnAcepHojsh); btnAcepHojsh.setBounds(600, 200, 71, 23); btnAcepRamas.setText("Aceptar");
117
Proyecto Final de Programacin I btnAcepRamas.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnAcepRamasActionPerformed(evt); } }); Panel.add(btnAcepRamas); btnAcepRamas.setBounds(600, 240, 71, 23); Panel.add(puntajeTotal); puntajeTotal.setBounds(420, 370, 330, 60); jLabel3.setText("P u n t a j e"); Panel.add(jLabel3); jLabel3.setBounds(440, 344, 110, 20); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(Panel, javax.swing.GroupLayout.DEFAULT_SIZE, 817, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(Panel, javax.swing.GroupLayout.DEFAULT_SIZE, 471, Short.MAX_VALUE) ); Castro Guia Reyes Romero
118
Proyecto Final de Programacin I pack(); }// </editor-fold> private void TalloIngActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: } private void btnCompararActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: } private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: submenudelJuego nuevo = new submenudelJuego (); nuevo.setVisible(true); this.setVisible(false); } private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: Color colorMensaje=new Color(9,53,140); if (jLabel1.getText().equals(RaizIng.getText())) { txtmensajeraiz.setText("Raiz"); RaizIng.setEnabled(false); txtmensajeraiz.setForeground(colorMensaje); AcpRaiz.setVisible(true); }
119
Proyecto Final de Programacin I else { RaizIng.setText(""); acu2=acu2+1; if (acu2==1) error3.setVisible(true); else if (acu2==2) error8.setVisible(true); else if (acu2==3) RaizIng.setEnabled(false); JOptionPane.showMessageDialog(this, "Lo siento amigo, tu respuesta " + "es incorecta"); } } private void RaizIngActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: } private void btnAcepTalloActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: Color colorMensaje=new Color(9,53,140);
if (JLabel2.getText().equals(TalloIng.getText()))
120
Proyecto Final de Programacin I { Txtmensaje.setText("Tallo"); TalloIng.setEnabled(false); Txtmensaje.setForeground(colorMensaje); AcpTallo.setVisible(true); } else { TalloIng.setText(""); acu=acu+1; if (acu==1) error1.setVisible(true); else if (acu==2) error6.setVisible(true); else if (acu==3) TalloIng.setEnabled(false); JOptionPane.showMessageDialog(this, "Lo siento amigo, tu respuesta " + "es incorecta"); } } private void btnAcepFrutoActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here:
121
Proyecto Final de Programacin I Color colorMensaje=new Color(9,53,140); if (jLabel5.getText().equals(FrutoIng.getText())) { txtmensajeFruto.setText("Fruto"); FrutoIng.setEnabled(false); txtmensajeFruto.setForeground(colorMensaje); AcpFrt.setVisible(true); } else {
FrutoIng.setText(""); acu1=acu1+1; if (acu1==1) error2.setVisible(true); else if (acu1==2) error7.setVisible(true); else if (acu1==3) FrutoIng.setEnabled(false); JOptionPane.showMessageDialog(this, "Lo siento amigo, tu respuesta " + "es incorecta"); } } private void btnAcepHojshActionPerformed(java.awt.event.ActionEvent evt) {
122
Proyecto Final de Programacin I // TODO add your handling code here: Color colorMensaje=new Color(9,53,140); if (jLabel6.getText().equals(HojasIng.getText())) { txtmensajehojas.setText("Raiz"); HojasIng.setEnabled(false); txtmensajehojas.setForeground(colorMensaje); AcpHojas.setVisible(true); } else { HojasIng.setText(""); acu3=acu3+1; if (acu3==1) error4.setVisible(true); else if (acu3==2) error9.setVisible(true); else if (acu3==3) HojasIng.setEnabled(false); JOptionPane.showMessageDialog(this, "Lo siento amigo, tu respuesta " + "es incorecta"); }
123
Proyecto Final de Programacin I } private void btnAcepRamasActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: Color colorMensaje=new Color(9,53,140);
if (jLabel4.getText().equals(RamasIng1.getText())) { txtmensajeramas.setText("Raiz"); RamasIng1.setEnabled(false); txtmensajeramas.setForeground(colorMensaje); AcpRamas.setVisible(true); } else { RamasIng1.setText(""); acu4=acu4+1; if (acu4==1) error5.setVisible(true); else if (acu4==2) error10.setVisible(true); else if (acu4==3) RamasIng1.setEnabled(false);
124
Proyecto Final de Programacin I JOptionPane.showMessageDialog(this, "Lo siento amigo, tu respuesta " + "es incorecta"); } } /** * @param args the command line arguments */ public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { Castro Guia Reyes Romero
125
/* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new ArbolJuego().setVisible(true); } }); } // Variables declaration - do not modify Castro Guia Reyes Romero
126
Proyecto Final de Programacin I private javax.swing.JLabel AcpFrt; private javax.swing.JLabel AcpHojas; private javax.swing.JLabel AcpRaiz; private javax.swing.JLabel AcpRamas; private javax.swing.JLabel AcpTallo; private javax.swing.JTextField FrutoIng; private javax.swing.JTextField HojasIng; private javax.swing.JLabel JLabel2; private javax.swing.JPanel Panel; private javax.swing.JTextField RaizIng; private javax.swing.JTextField RamasIng1; private javax.swing.JTextField TalloIng; private javax.swing.JLabel Txtmensaje; private javax.swing.JButton btnAcepFruto; private javax.swing.JButton btnAcepHojsh; private javax.swing.JButton btnAcepRamas; private javax.swing.JButton btnAcepTallo; private javax.swing.JButton btnComparar; private javax.swing.JLabel error1; private javax.swing.JLabel error10; private javax.swing.JLabel error2; private javax.swing.JLabel error3; private javax.swing.JLabel error4; private javax.swing.JLabel error5;
127
Proyecto Final de Programacin I private javax.swing.JLabel error6; private javax.swing.JLabel error7; private javax.swing.JLabel error8; private javax.swing.JLabel error9; private javax.swing.JButton jButton1; private javax.swing.JButton jButton8; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel10; private javax.swing.JLabel jLabel11; private javax.swing.JLabel jLabel12; private javax.swing.JLabel jLabel13; private javax.swing.JLabel jLabel14; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; private javax.swing.JLabel jLabel5; private javax.swing.JLabel jLabel6; private javax.swing.JLabel jLabel8; private javax.swing.JLabel jLabel9; private javax.swing.JLabel puntajeTotal; private javax.swing.JLabel txtmensajeFruto; private javax.swing.JLabel txtmensajehojas; private javax.swing.JLabel txtmensajeraiz; private javax.swing.JLabel txtmensajeramas; // End of variables declaration
128
Proyecto Final de Programacin I } Juego de Nombres de Animales package juegodeponerpartes; public class JuegoDeNombreAnimales extends javax.swing.JFrame { public JuegoDeNombreAnimales() { initComponents(); } @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() { jButton1 = new javax.swing.JButton(); jButton2 = new javax.swing.JButton(); jButton3 = new javax.swing.JButton(); jLabel1 = new javax.swing.JLabel(); jButton4 = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); jButton1.setText("Mamiferos"); jButton2.setText("Hervivoros"); jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton2ActionPerformed(evt); } }); jButton3.setText("Carnivoros"); jLabel1.setText("Los animales se clasifican en:"); Castro Guia Reyes Romero
129
Proyecto Final de Programacin I jButton4.setText("Atras"); jButton4.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton4ActionPerformed(evt); } }); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(66, 66, 66) .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 133, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(25, 25, 25) .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 133, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(39, 39, 39) .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 133, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(47, Short.MAX_VALUE)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,
130
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN G) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 192, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(182, 182, 182)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addComponent(jButton4) .addGap(251, 251, 251)))) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(53, 53, 53) .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(57, 57, 57)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELIN E) .addComponent(jButton3)
131
Proyecto Final de Programacin I .addComponent(jButton1) .addComponent(jButton2)) .addGap(40, 40, 40) .addComponent(jButton4) .addContainerGap(71, Short.MAX_VALUE)) ); pack(); }// </editor-fold> private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: GrupoHervivoros nuevo = new GrupoHervivoros(); nuevo.setVisible(true); this.setVisible(false); } private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: submenudelJuego nuevo = new submenudelJuego(); nuevo.setVisible(true); this.setVisible(true); } /** * @param args the command line arguments */ public static void main(String args[]) {
132
Proyecto Final de Programacin I /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) {
133
Proyecto Final de Programacin I java.util.logging.Logger.getLogger(JuegoDeNombreAnimales.class.getName()).log(ja va.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(JuegoDeNombreAnimales.class.getName()).log(ja va.util.logging.Level.SEVERE, null, ex); } //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new JuegoDeNombreAnimales().setVisible(true); } }); } // Variables declaration - do not modify private javax.swing.JButton jButton1; private javax.swing.JButton jButton2; private javax.swing.JButton jButton3; private javax.swing.JButton jButton4; private javax.swing.JLabel jLabel1; // End of variables declaration } Algoritmo Grupo Hervivoros package juegodeponerpartes;
134
Proyecto Final de Programacin I import java.awt.Color; import javax.swing.JOptionPane; public class GrupoHervivoros extends javax.swing.JFrame { public GrupoHervivoros() { initComponents(); } @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() { jPanel1 = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); ingrVaca = new javax.swing.JTextField(); jButton1 = new javax.swing.JButton(); jButton2 = new javax.swing.JButton(); jButton3 = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); jPanel1.setLayout(null); jLabel1.setText("Identifica este animal:"); jPanel1.add(jLabel1); jLabel1.setBounds(30, 30, 120, 30); jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Vaquita.png"))); // NOI18N jPanel1.add(jLabel2); Castro Guia Reyes Romero
135
Proyecto Final de Programacin I jLabel2.setBounds(130, 50, 210, 230); ingrVaca.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { ingrVacaActionPerformed(evt); } }); jPanel1.add(ingrVaca); ingrVaca.setBounds(80, 280, 110, 30); jButton1.setText("Aceptar"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); jPanel1.add(jButton1); jButton1.setBounds(100, 320, 71, 23); jButton2.setText("Siguiente"); jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton2ActionPerformed(evt); } }); jPanel1.add(jButton2); jButton2.setBounds(290, 280, 80, 23);
136
Proyecto Final de Programacin I jButton3.setText("Atras"); jButton3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton3ActionPerformed(evt); } }); jPanel1.add(jButton3); jButton3.setBounds(290, 320, 80, 23); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 475, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 372, Short.MAX_VALUE) ); pack(); }// </editor-fold> private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: Castro Guia Reyes Romero
137
Proyecto Final de Programacin I String vacaIngresado=ingrVaca.getText(); { if (vacaIngresado.equals("Vaca")||vacaIngresado.equals("vaca")|| vacaIngresado.equals("VACA")) { JOptionPane.showMessageDialog(this,"La VACA es un animal mamfero,\n" + "nace vivo del vientre de la madre.\n" + "Es tambin vertebrado porque tiene huesos\n" + "y herbvoro porque se\n" + "alimenta de hierba y pastos."); ingrVaca.enable(false); } else { ingrVaca.setText(""); ingrVaca.enable(false); JOptionPane.showMessageDialog(this, "Lo siento amigo, prueva con el " + "siguiente animal :)"); } } } private void ingrVacaActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: }
138
Proyecto Final de Programacin I private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: GrupoHervivoros2 nuevo = new GrupoHervivoros2(); nuevo.setVisible(true); this.setVisible(false); } private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: JuegoDeNombreAnimales nuevo = new JuegoDeNombreAnimales(); nuevo.setVisible(true); this.setVisible(false); } /** * @param args the command line arguments */ public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { Castro Guia Reyes Romero
139
Proyecto Final de Programacin I for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(GrupoHervivoros.class.getName()).log(java.util.log ging.Level.SEVERE, null, ex); } //</editor-fold> /* Create and display the form */
140
Proyecto Final de Programacin I java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new GrupoHervivoros().setVisible(true); } }); } // Variables declaration - do not modify private javax.swing.JTextField ingrVaca; private javax.swing.JButton jButton1; private javax.swing.JButton jButton2; private javax.swing.JButton jButton3; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JPanel jPanel1; // End of variables declaration } Algoritmo Grupo Hervivoros 2 package juegodeponerpartes; import javax.swing.JOptionPane; public class GrupoHervivoros2 extends javax.swing.JFrame { public GrupoHervivoros2() { initComponents(); } @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> Castro Guia Reyes Romero
141
Proyecto Final de Programacin I private void initComponents() { jPanel1 = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); ingrElefante = new javax.swing.JTextField(); jButton1 = new javax.swing.JButton(); jButton2 = new javax.swing.JButton(); jButton3 = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); jPanel1.setLayout(null); jLabel1.setText("Identifica este animal:"); jPanel1.add(jLabel1); jLabel1.setBounds(30, 30, 120, 30); jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/elefantitu.png"))); // NOI18N jPanel1.add(jLabel2); jLabel2.setBounds(130, 50, 210, 230); ingrElefante.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { ingrElefanteActionPerformed(evt); } }); jPanel1.add(ingrElefante); ingrElefante.setBounds(80, 280, 110, 30); Castro Guia Reyes Romero
142
Proyecto Final de Programacin I jButton1.setText("Aceptar"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); jPanel1.add(jButton1); jButton1.setBounds(100, 320, 71, 23); jButton2.setText("Siguiente"); jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton2ActionPerformed(evt); } }); jPanel1.add(jButton2); jButton2.setBounds(290, 280, 80, 23); jButton3.setText("Menu"); jButton3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton3ActionPerformed(evt); } }); jPanel1.add(jButton3); jButton3.setBounds(290, 320, 80, 23);
143
Proyecto Final de Programacin I javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 480, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 380, Short.MAX_VALUE) );
pack(); }// </editor-fold> private void ingrElefanteActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: } private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: String elefanteIngresado=ingrElefante.getText(); { if (elefanteIngresado.equals("Elefante")|| elefanteIngresado.equals("elefante")||elefanteIngresado.equals("ELEFANTE")) Castro Guia Reyes Romero
144
Proyecto Final de Programacin I { JOptionPane.showMessageDialog(this,"Es el animal terrestre ms grande del mundo,\n " +"a los elefante los podemos identificar por sus gigantes\n" +"orejas, estos animales comen races, frutas,\n" +"cortezas y todo tipo de cosas relacionadas.\n" +"Pueden llegar a comer unos 136 kilogramos al da de comida.\n"); ingrElefante.enable(false); } else { ingrElefante.setText(""); ingrElefante.enable(false); JOptionPane.showMessageDialog(this, "Lo siento amigo, prueva con el " + "siguiente animal :)"); } } } private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: JuegoDeNombreAnimales nuevo = new JuegoDeNombreAnimales(); nuevo.setVisible(true); this.setVisible(false); Castro Guia Reyes Romero
145
Proyecto Final de Programacin I } private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: GrupoHervivoros2 nuevo = new GrupoHervivoros2(); nuevo.setVisible(true); this.setVisible(false); } /** * @param args the command line arguments */ public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; Castro Guia Reyes Romero
146
java.util.logging.Logger.getLogger(GrupoHervivoros2.class.getName()).log(java.util.lo gging.Level.SEVERE, null, ex); } //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new GrupoHervivoros2().setVisible(true); } }); Castro Guia Reyes Romero
147
Proyecto Final de Programacin I } // Variables declaration - do not modify private javax.swing.JTextField ingrElefante; private javax.swing.JButton jButton1; private javax.swing.JButton jButton2; private javax.swing.JButton jButton3; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JPanel jPanel1; // End of variables declaration }
148
Luego de aceptar se presenta otro mensaje en donde si deseamos jugar debemos dar clip en aceptar.
149
Luego aparece un menu en donde se despliega dos opciones las cuales son colocar las partes del arbol y colocar el nombre a los animales.
Figura 23: Algorirmo Sub Men Al seleccionar la opcion colocar las partes del arbol nos aparece la siguiente imagen, en donde se debe colocar los numero a sus partes segun se proyecten en la imagen del arbol, estos numeros son aleatorios.
150
En cambio al seleccionar la opcion colocar los nombres a los animales se despliega el siguiente mensaje en donde esta la clasificacion de los mismos.
Al seleccionar hervivoros nos aparecera una imagen en donde debemos identificar que animal es y poner su nombre; si el nombre ingresado es el correcto aparecera un mensaje mostrando la descripcion de este animal.
151
Al seleccionar hervivoros nos aparecera una imagen en donde debemos identificar que animal es y poner su nombre; si el nombre ingresado es el correcto aparecera un mensaje mostrando la descripcion de este animal.
Figura 27: Algoritmo Grupo Hervivoros 2 Al seleccionar carnivoros nos aparecera una imagen en donde debemos identificar que animal es y poner su nombre; si el nombre ingresado es el correcto aparecera un mensaje mostrando la descripcion de este animal.
Al seleccionar mamiferos nos aparecera una imagen en donde debemos identificar que animal es y poner su nombre; si el nombre ingresado es el correcto aparecera un mensaje mostrando la descripcion de este animal.
152