Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ESTE METODO RECORRE MI ARREGLO DE GENOTIPOS Y ME DICE SI LO QUE ENTRA COMO PARAMETRO ES IGUAL O NO A LO QUE GUARDE EN EL ARREGLO
- public boolean esCorrecto (String info) throws Exception
- {
- boolean seAcepta = false;
- for(int i = 0 ; i< darGenotipo().length && seAcepta == false ; i++)
- {
- String genotipo = darGenotipo()[i].darAlelo();
- if(info.equals(genotipo))
- {
- seAcepta = true;
- }
- }
- if(seAcepta == false)
- {
- throw new Exception ("Porfavor ingrese un fenotipo valido");
- }
- else
- return seAcepta;
- }
- Y EL CREAR ENTONCS ME QUEDARIA ASI EN LA INTERFAZ, EL DEL MUNDO ES EL QUE USTED YA TIENE EL FELICIDAD 2 JAJA
- public void crear()
- {
- String padre = (String)JOptionPane.showInputDialog(this, "Genotipo Padre: ", "Crear Cuadro de Punnett", JOptionPane.QUESTION_MESSAGE);
- try
- {
- esCorrecto(padre);
- if(padre != null && !padre.equals("") )
- {
- String madre = (String)JOptionPane.showInputDialog(this, "Genotipo Madre: ", "Crear Cuadro de Punnett" , JOptionPane.QUESTION_MESSAGE);
- try
- {
- esCorrecto(madre);
- if(madre!=null && !madre.equals(""))
- {
- calculadoraPunnett.crear(padre, madre);
- }
- }
- catch(Exception e)
- {
- }
- // Tuve que hacer este condicional porque si lo dejaba que fuera manejado por el catch,
- // siempre me iba a salir la excepcion sin importar que el fenotipo estuviese escrito bien.
- // No entiendo porque sucede esto, y lo revise de muchas maneras.
- if( esCorrecto(madre) == false)
- {
- JOptionPane.showMessageDialog(this, "Por favor ingrese un fenotipo valido " , "Error", JOptionPane.ERROR_MESSAGE);
- }
- }
- }
- catch(Exception e)
- {
- JOptionPane.showMessageDialog(this, e.getMessage() , "Error", JOptionPane.ERROR_MESSAGE);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement