import javabook.*;
class GUIFunciones {
  MainWindow ventana;
  Coordenada punto;
  void iniciar() {
    ventana = new MainWindow("GUIFunciones");ventana.show();
    punto=new Coordenada();
  }
  void entradaX() {
    InputBox entrada= new InputBox(ventana);
    punto.x = entrada.getDouble("Dame x");  
  }
  void menuCurva() {
    ListBox lista = new ListBox(ventana);
    lista.addItem("Linea Recta");
    lista.addItem("Distribucion Gauss");
    int opcion = lista.getSelectedIndex();
    if (opcion!=ListBox.CANCEL && 
         opcion!=ListBox.NO_SELECTION ){
       switch (opcion) {
        case 0: LineaRecta l= new LineaRecta();
             l.pendiente=1;l.ordenada=1;
             l.punto=new Coordenada(); l.calcular(punto);
             punto.y = l.punto.y;
             break;
        case 1:DistribucionGauss g= new DistribucionGauss();
             g.media=0;g.sigma=1;
             g.punto=new Coordenada(); g.calcular(punto);
             punto.y = g.punto.y;
             break;
          default: break;
       }
    }
  }
  void imprimirY() {
     OutputBox salida= new OutputBox(ventana);
     salida.show(); salida.printLine(" Y = "+punto.y);
  }  
  void trabajar() {
     boolean salir=false;
     iniciar();
     do {
        entradaX();
        menuCurva();
        imprimirY();
        ResponseBox pregunta = new ResponseBox(ventana);
        int continuar = pregunta.prompt("Continuar?");
        salir = (continuar== ResponseBox.NO);     
     } while (!salir); 
  }
}