Top Banner

of 25

Informe de Proyecto Programación II

Feb 22, 2018

Download

Documents

Bryan Rodriguez
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
  • 7/24/2019 Informe de Proyecto Programacin II

    1/25

    Informe de Proyecto Programacin II

    Nombre: Bryan Edgardo Rodrguez Garca

    N de Cuenta: 31241249

    Fecha de entrega: 27/06/2015

  • 7/24/2019 Informe de Proyecto Programacin II

    2/25

    Descripcin de problema.

    Apartamentos Rodrguez

    Una pequea empresa que se dedica a alquilar apartamentos ofrece los siguientes

    dependiendo contrato:

    Clasificacin Descripcin Tipo de alquiler

    1 Sencillo (1 Habitacin) L. 3500.00

    2 Doble (2 Habitaciones) L. 6000.00

    Por polticas de la empresa solo se ofrecen 2 tipos de contrato: 6 meses y 12 meses para

    alquilar para ambos apartamentos.

    Para el apartamento sencillo se ofrecen con camas personales y para el doble se ofrecen con

    camas matrimoniales.

    Para el apartamento sencillo se ofrece servicio de parqueo a L.1000.00 y servicios

    acondicionantes a L. 1500.00 sin importar el tipo de contracto.

    Para el apartamento doble se ofrece servicio de parqueo a L.2000.00 y servicios

    acondicionantes a L. 2500.00 sin importar el tipo de contracto.

  • 7/24/2019 Informe de Proyecto Programacin II

    3/25

    Presentacin de cdigo fuente

    Clase inicial del Programa (Contiene mtodo MAIN)

    package javaapplication28;

    public class JavaApplication28 { // Clase Inicial del programa

    public static void main(String[] args) { // Metodo MAIN de la Clase JavaApplication28

    principal objetoPrincipal = new principal(); // Llamada de clase Principal

    objetoPrincipal.setInicio(); // Llamada de metodo setInicio en clase Principal.

    }

    }

  • 7/24/2019 Informe de Proyecto Programacin II

    4/25

    Clase publica Entrada (Ventana Grfica)

    package javaapplication28; // Paquete del programa

    public class entrada extends javax.swing.JFrame { // Clase publica JFrame (Grafico)

    private String nom=""; // Declaracin de variable String

    private double identi,apartamento,sp,sa; // Declaracin de variable Double

    private boolean op1, op2 , op3 ,op4, s , n ,pos ,neg; // Declaracin de variable boolean

    public entrada() { // Creacin de constructor de la clase "entrada"

    initComponents(); // Inicializacin de componentes.

    this.nom = ""; // Inicializacin de Variable String

    this.identi = 0; // Inicializacin de Variable Double

    this.op1 = false; // Inicializacin de Variable boolean

    this.op2 = false; // Inicializacin de Variable boolean

    this.op3 = false; // Inicializacin de Variable boolean

    this.op4 = false; // Inicializacin de Variable boolean

    this.s = false; // Inicializacin de Variable boolean

    this.n = false; // Inicializacin de Variable boolean

    this.pos = false; // Inicializacin de Variable boolean

    this.neg = false; // Inicializacin de Variable boolean

    this.apartamento = 0; // Inicializacin de Variable Double

    this.sp = 0; // Inicializacin de Variable Double

    this.sa = 0; // Inicializacin de Variable Double

    }

    @SuppressWarnings("unchecked")

  • 7/24/2019 Informe de Proyecto Programacin II

    5/25

    //

    private void initComponents() {

    buttonGroup1 = new javax.swing.ButtonGroup();

    buttonGroup2 = new javax.swing.ButtonGroup();

    buttonGroup3 = new javax.swing.ButtonGroup();

    buttonGroup4 = new javax.swing.ButtonGroup();

    jLabel1 = new javax.swing.JLabel();

    texto1 = new javax.swing.JLabel();

    nombre = new javax.swing.JTextField();

    texto2 = new javax.swing.JLabel();

    identidad = new javax.swing.JTextField();

    jLabel4 = new javax.swing.JLabel();

    opcion1 = new javax.swing.JRadioButton();

    opcion2 = new javax.swing.JRadioButton();

    jLabel5 = new javax.swing.JLabel();

    si = new javax.swing.JRadioButton();

    no = new javax.swing.JRadioButton();

    jLabel6 = new javax.swing.JLabel();

    opcion3 = new javax.swing.JRadioButton();

    opcion4 = new javax.swing.JRadioButton();

    jLabel7 = new javax.swing.JLabel();

    positivo = new javax.swing.JRadioButton();

    negativo = new javax.swing.JRadioButton();

    ejecutar = new javax.swing.JButton();

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

    jLabel1.setText("Bienvenidos a Apartamentos Rodriguez");

    texto1.setText("Escriba su nombre :");

    nombre.addActionListener(new java.awt.event.ActionListener() {

    public void actionPerformed(java.awt.event.ActionEvent evt) {

    nombreActionPerformed(evt);

  • 7/24/2019 Informe de Proyecto Programacin II

    6/25

    }

    });

    texto2.setText("Numero de identidad :");

    jLabel4.setText("Que tipo de apartamento desea alquilar?");

    buttonGroup1.add(opcion1);

    opcion1.setText("Sencillo (una habitacion)");

    buttonGroup1.add(opcion2);

    opcion2.setText("Doble (dos habitaciones)");

    opcion2.addActionListener(new java.awt.event.ActionListener() {

    public void actionPerformed(java.awt.event.ActionEvent evt) {

    opcion2ActionPerformed(evt);

    }

    });

    jLabel5.setText("Desea incluir pago de parqueo?");

    buttonGroup3.add(si);

    si.setText("Si");

    si.addActionListener(new java.awt.event.ActionListener() {

    public void actionPerformed(java.awt.event.ActionEvent evt) {

    siActionPerformed(evt);

    }

    });

    buttonGroup3.add(no);

    no.setText("No");

    jLabel6.setText("Cuanto tiempo desea alquilar el apartamento?");

    buttonGroup2.add(opcion3);

    opcion3.setText("6 meses");

  • 7/24/2019 Informe de Proyecto Programacin II

    7/25

    buttonGroup2.add(opcion4);

    opcion4.setText("1 ao");

    jLabel7.setText("Desea incluir plan con servicios acondicionantes?");

    buttonGroup4.add(positivo);

    positivo.setText("Si");

    buttonGroup4.add(negativo);

    negativo.setText("No");

    ejecutar.setText("Calcular");

    ejecutar.addActionListener(new java.awt.event.ActionListener() {

    public void actionPerformed(java.awt.event.ActionEvent evt) {

    ejecutarActionPerformed(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(18, 18, 18)

    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

    .addGroup(layout.createSequentialGroup()

    .addComponent(positivo)

    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

    .addComponent(negativo))

    .addComponent(jLabel7)

    .addComponent(opcion4)

    .addComponent(opcion3)

    .addComponent(jLabel6)

    .addComponent(jLabel5)

  • 7/24/2019 Informe de Proyecto Programacin II

    8/25

    .addComponent(opcion2)

    .addComponent(opcion1)

    .addComponent(jLabel4)

    .addGroup(layout.createSequentialGroup()

    .addComponent(texto2)

    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

    .addComponent(identidad, javax.swing.GroupLayout.PREFERRED_SIZE, 238,

    javax.swing.GroupLayout.PREFERRED_SIZE))

    .addGroup(layout.createSequentialGroup()

    .addComponent(texto1)

    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)

    .addComponent(nombre, javax.swing.GroupLayout.PREFERRED_SIZE, 244,

    javax.swing.GroupLayout.PREFERRED_SIZE))

    .addGroup(layout.createSequentialGroup()

    .addComponent(si)

    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

    .addComponent(no)))

    .addContainerGap(104, 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.LEADING)

    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()

    .addComponent(jLabel1)

    .addGap(135, 135, 135))

    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()

    .addComponent(ejecutar, javax.swing.GroupLayout.PREFERRED_SIZE, 129,

    javax.swing.GroupLayout.PREFERRED_SIZE)

    .addGap(29, 29, 29))))

    );

    layout.setVerticalGroup(

    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

    .addGroup(layout.createSequentialGroup()

    .addContainerGap()

    .addComponent(jLabel1)

    .addGap(18, 18, 18)

    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

  • 7/24/2019 Informe de Proyecto Programacin II

    9/25

    .addComponent(texto1)

    .addComponent(nombre, javax.swing.GroupLayout.PREFERRED_SIZE,

    javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

    .addGap(18, 18, 18)

    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

    .addComponent(texto2)

    .addComponent(identidad, javax.swing.GroupLayout.PREFERRED_SIZE,

    javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

    .addGap(18, 18, 18)

    .addComponent(jLabel4)

    .addGap(18, 18, 18)

    .addComponent(opcion1)

    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)

    .addComponent(opcion2)

    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)

    .addComponent(jLabel6)

    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

    .addComponent(opcion3)

    .addGap(1, 1, 1)

    .addComponent(opcion4)

    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)

    .addComponent(jLabel5)

    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

    .addComponent(si)

    .addComponent(no))

    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

    .addComponent(jLabel7)

    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)

    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

    .addComponent(positivo)

    .addComponent(negativo))

    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

    .addComponent(ejecutar, javax.swing.GroupLayout.PREFERRED_SIZE, 34,

    javax.swing.GroupLayout.PREFERRED_SIZE)

    .addContainerGap(20, Short.MAX_VALUE))

  • 7/24/2019 Informe de Proyecto Programacin II

    10/25

    );

    pack();

    }//

    private void nombreActionPerformed(java.awt.event.ActionEvent evt) {

    }

    private void opcion2ActionPerformed(java.awt.event.ActionEvent evt) {

    }

    private void siActionPerformed(java.awt.event.ActionEvent evt) {

    }

    private void ejecutarActionPerformed(java.awt.event.ActionEvent evt) {

    principal objetoPrincipal = new principal(); // llamada a la clase "principal"

    boolean bandera; //Declaracin de Variable boolean

    texto2.setText(""); // Declaracin para mostrar texto

    bandera=false; // Actualizacin de variable

    try{ // Manejo de errores (en el cual se intentara ejecutar siguiente codigo)

    this.identi= Double.parseDouble(identidad.getText()); // Codigo a ejecutar sujeto a condicionante

    }

    catch(Exception e){ // Si no se ejecuta codigo enviar excepcion

    identidad.setText(""); // Declaracin para mostrar Texto

    texto2.setText("Solo se admiten numeros enteros sin guiones"); // Texto a mostar en caso de error

    bandera = true; // Si cumple con los requisitos variable se actualiza

    }

  • 7/24/2019 Informe de Proyecto Programacin II

    11/25

    if (opcion1.isSelected()) // Si variable es seleccionada

    op1=true; // Actualizar Variable

    if (opcion2.isSelected()) // Si variable es seleccionada

    op2=true; // Actualizar Variable

    if (opcion3.isSelected()) // Si variable es seleccionada

    op3=true; // Actualizar Variable

    if (opcion4.isSelected()) // Si variable es seleccionada

    op4=true; // Actualizar Variable

    if(si.isSelected()) // Si variable es seleccionada

    s=true; // Actualizar Variable

    if(no.isSelected()) // Si variable es seleccionada

    n=true; // Actualizar Variable

    if(positivo.isSelected()) // Si variable es seleccionada

    pos=true; // Actualizar Variable

    if(negativo.isSelected()) // Si variable es seleccionada

    neg=true; // Actualizar Variable

    if (!bandera){ // Condicionante si variable se ejecuta

    this.setVisible(false); // No mostrar pantalla

    objetoPrincipal.setActualizar(sa, sp, nom, identi, apartamento, op1, op2, op3, op4, s, n, pos, neg); // Metodo

    para actualizar variable de la clase "principal"

    }

    }

    public static void main(String args[]) {

    //

    /* 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;

  • 7/24/2019 Informe de Proyecto Programacin II

    12/25

    }

    }

    } catch (ClassNotFoundException ex) {

    java.util.logging.Logger.getLogger(entrada.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);

    } catch (InstantiationException ex) {

    java.util.logging.Logger.getLogger(entrada.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);

    } catch (IllegalAccessException ex) {

    java.util.logging.Logger.getLogger(entrada.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);

    } catch (javax.swing.UnsupportedLookAndFeelException ex) {

    java.util.logging.Logger.getLogger(entrada.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);

    }

    //

    java.awt.EventQueue.invokeLater(new Runnable() {

    public void run() {

    new entrada().setVisible(true);

    }

    });

    }

    public String getNombre() { // Metodo para regresar variable

    return nom; // Variable a regresar

    }

    public double getIdentidad(){ // Metodo para regresar variable

    return identi; // Variable a regresar

    }

    public boolean isOp1() { // Metodo para regresar variable

    return op1; // Variable a regresar

    }

    public boolean isOp2() { // Metodo para regresar variable

  • 7/24/2019 Informe de Proyecto Programacin II

    13/25

    return op2; // Variable a regresar

    }

    public boolean isOp3() { // Metodo para regresar variable

    return op3; // Variable a regresar

    }

    public boolean isOp4() { // Metodo para regresar variable

    return op4; // Variable a regresar

    }

    public boolean isS(){ // Metodo para regresar variable

    return s; // Variable a regresar

    }

    public boolean isN(){ // Metodo para regresar variable

    return n; // Variable a regresar

    }

    public boolean isPos(){ // Metodo para regresar variable

    return pos; // Variable a regresar

    }

    public boolean isNeg(){ // Metodo para regresar variable

    return neg; // Variable a regresar

    }

    // Declaracin de variables no modificables

    private javax.swing.ButtonGroup buttonGroup1;

    private javax.swing.ButtonGroup buttonGroup2;

    private javax.swing.ButtonGroup buttonGroup3;

    private javax.swing.ButtonGroup buttonGroup4;

    private javax.swing.JButton ejecutar;

  • 7/24/2019 Informe de Proyecto Programacin II

    14/25

    private javax.swing.JTextField identidad;

    private javax.swing.JLabel jLabel1;

    private javax.swing.JLabel jLabel4;

    private javax.swing.JLabel jLabel5;

    private javax.swing.JLabel jLabel6;

    private javax.swing.JLabel jLabel7;

    private javax.swing.JRadioButton negativo;

    private javax.swing.JRadioButton no;

    private javax.swing.JTextField nombre;

    private javax.swing.JRadioButton opcion1;

    private javax.swing.JRadioButton opcion2;

    private javax.swing.JRadioButton opcion3;

    private javax.swing.JRadioButton opcion4;

    private javax.swing.JRadioButton positivo;

    private javax.swing.JRadioButton si;

    private javax.swing.JLabel texto1;

    private javax.swing.JLabel texto2;

    // Final de declaracin de variables.

    }

    Captura de pantalla de la clase entrada

  • 7/24/2019 Informe de Proyecto Programacin II

    15/25

    Clase publica principal

    package javaapplication28;

    import javax.swing.JOptionPane; // Libreria exportada para JoptionPane

    public class principal { // Clase publica "principal"

    private String nombre=""; // Declaracin variables String

    private double identidad,apartamento,total,tiempo,sa,sp;// Declaracin variables Double

    private boolean opcion1,opcion2,opcion3,opcion4,si,no,positivo,negativo; // Declaracin variables Boolean

    public principal() { // Creacin de constructor de la clase "Principal"

    this.nombre= ""; // Inicializacin de Variable String

    this.identidad = 0; // Inicializacin de Variable Double

    this.apartamento= 0; // Inicializacin de Variable Double

    this.tiempo = 0; // Inicializacin de Variable Double

    this.sp = 0; // Inicializacin de Variable Double

    this.sa = 0; // Inicializacin de Variable Double

    this.opcion1 = false; // Inicializacin de Variable boolean

    this.opcion2 = false; // Inicializacin de Variable boolean

    this.opcion3 = false; // Inicializacin de Variable boolean

    this.opcion4 = false; // Inicializacin de Variable boolean

    this.si = false; // Inicializacin de Variable boolean

    this.no = false; // Inicializacin de Variable boolean

    this.positivo = false; // Inicializacin de Variable boolean

    this.negativo = false; // Inicializacin de Variable boolean

    }

    public void setInicio(){ // Declaracin de metodo setInicio

    entrada objetoentrada = new entrada(); // Llamada a la clase "entrada"

  • 7/24/2019 Informe de Proyecto Programacin II

    16/25

    objetoentrada.setVisible(true); // Controla que componente sea mostrada en la siguiente pantalla

    }

    public void setActualizar(double sa, double sp,String nom,double identi,double apartamento, boolean op1 ,

    boolean op2 , boolean op3 ,boolean op4, boolean s , boolean n,boolean pos, boolean neg){ // Declaracion deMetodo setActualizar para actualizar las variables de clase.

    calculo calculoobjeto = new calculo(); // Llamado de clase calculo

    salida salidaobjeto = new salida(); // Llamado de clase salida

    this.nombre = nom; // Actualizacin de Variable String

    this.identidad = identi; // Actualizacin de Variable Double

    this.opcion1 = op1; // Actualizacin de Variable boolean

    this.opcion2 = op2; // Actualizacin de Variable boolean

    this.opcion3 = op3; // Actualizacin de Variable boolean

    this.opcion4 = op4; // Actualizacin de Variable boolean

    this.si = s; // Actualizacin de Variable boolean

    this.no = n; // Actualizacin de Variable boolean

    this.positivo = pos; // Actualizacin de Variable boolean

    this.negativo = neg; // Actualizacin de Variable boolean

    this.sa = sa; // Actualizacin de Variable boolean

    this.sp = sp; // Actualizacin de Variable boolean

    calculoobjeto.setInicio(sa, sp, nom, identi, apartamento, tiempo, op1, op2, op3, op4, s, n, pos, neg); //

    Declaracin de metodo setInicio con parametros actualizados de la clase calculo

    this.total = calculoobjeto.getTotal(); // Llamado de Variable "total" Actualizada de clase "calculo"

    salidaobjeto.setInicio(total); // Llamada de metodo setInicio desde clase "salida"

    }

    public void setSalida(){ // creacin de metodo setSalida

    int resp; // Varible Integer

    resp = JOptionPane.showConfirmDialog(null, "Desea continuar"); // Mensaje ha mostrar cuando se ejecute el

    metodo

    if(resp==JOptionPane.YES_OPTION) // Condicionante al llamar al metodo eligiendo una variable

    setInicio(); // Llamada de metodo desde clase "salida"

    else // Condicionante en caso contrario de no llamar a la variable

    System.exit(0); // Salir del programa

    }

    }

  • 7/24/2019 Informe de Proyecto Programacin II

    17/25

    Clase Publica calculo

    package javaapplication28;

    import javax.swing.JOptionPane;

    public class calculo { // Declaracin de clase publica "calculo"

    private String nombre=""; // Declaracin variables String

    private double identidad,apartamento,total,tiempo,sa,sp; // Declaracin variables Double

    private boolean opcion1,opcion2,opcion3,opcion4,si,no,positivo,negativo; // Declaracin variables boolean

    public calculo() {

    this.nombre= ""; // Inicializacin de Variable String

    this.identidad = 0; // Inicializacin de Variable Double

    this.apartamento= 0; // Inicializacin de Variable Double

    this.tiempo = 0; // Inicializacin de Variable Double

    this.sa = 0; // Inicializacin de Variable Double

    this.sp = 0; // Inicializacin de Variable Double

    this.opcion1 = false; // Inicializacin de Variable boolean

    this.opcion2 = false; // Inicializacin de Variable boolean

    this.opcion3 = false; // Inicializacin de Variable boolean

    this.opcion4 = false; // Inicializacin de Variable boolean

    this.si = false; // Inicializacin de Variable boolean

    this.no = false; // Inicializacin de Variable boolean

    this.positivo = false; // Inicializacin de Variable boolean

    this.negativo = false; // Inicializacin de Variable boolean

    }

    public void setInicio(){ // Declaracin de metodo setInicio

    entrada objetoentrada = new entrada(); // Llamada a la clase "entrada"

    objetoentrada.setVisible(true); // Controla que componente sea mostrada en la siguiente pantalla

    }

  • 7/24/2019 Informe de Proyecto Programacin II

    18/25

    public void setInicio(double sa, double sp,String nom,double identi,double apartamento,double tiempo,boolean

    op1, boolean op2 , boolean op3,boolean op4, boolean s , boolean n,boolean pos , boolean neg){ // Declaracion de

    Metodo setInicio para actualizar las variables de clase.

    this.nombre = nom; // Actualizacin de Variable String

    this.identidad = identi; // Actualizacin de Variable Double

    this.apartamento = apartamento; // Actualizacin de Variable Double

    this.tiempo = tiempo; // Actualizacin de Variable Double

    this.total = total; // Actualizacin de Variable Double

    this.sa = sa; // Actualizacin de Variable Double

    this.sp = sp; // Actualizacin de Variable Double

    this.opcion1 = op1; // Actualizacin de Variable boolean

    this.opcion2 = op2; // Actualizacin de Variable boolean

    this.opcion3 = op3; // Actualizacin de Variable boolean

    this.opcion4 = op4; // Actualizacin de Variable boolean

    this.si = s; // Actualizacin de Variable boolean

    this.no = n; // Actualizacin de Variable boolean

    this.positivo = pos; // Actualizacin de Variable boolean

    this.negativo = neg; // Actualizacin de Variable boolean

    calcular(); // Ejecucin de metodo "calcular"

    }

    private void calcular(){ // Metodo privado calcular

    if(this.opcion1){ // Condicionante si elige opcion 1

    JOptionPane.showMessageDialog(null, "El apartamento sencillo incluye cama personal"); // Mostrar Mensaje

    if(this.opcion3){ // Condicionante si elige opcion 3

    apartamento = 3500 * 6; // Calculo de la variable apartamento

  • 7/24/2019 Informe de Proyecto Programacin II

    19/25

    JOptionPane.showMessageDialog(null, "Se cobrara 3,500 lps mensuales por el apartamento sencillo durante 6

    meses"); // Mostrar Mensaje

    }

    if(this.opcion4){ // Condicionante si elige opcion 4

    apartamento = 3500 * 12; // Calculo de la variable apartamento

    JOptionPane.showMessageDialog(null, "Se cobrara 3,500 lps mensuales por el apartamento sencillo durante 12

    meses"); // Mostrar Mensaje

    }

    if(this.si){ // Condicionante si elige si

    sp = 500; // Calculo de la variable sp

    JOptionPane.showMessageDialog(null, "Se cobrara 1000 lps por servicio de parqueo"); // Mostrar Mensaje

    }

    if(this.no){ // Condicionante si elige no

    sp = 0; // Calculo de la variable sp

    }

    if(this.positivo){ // Condicionante si elige positivo

    sa = 450; // Calculo de la variable sa

    JOptionPane.showMessageDialog(null, "Se cobrara 1500 lps por servicios de internet y mantenimiento de aire

    acondicionado"); // Mostrar Mensaje

    }

    if(this.negativo){ // Condicionante si elige negativo

    sa = 0; // Calculo de la variable sa

    }}

    if(this.opcion2){ // Condicionante si elige opcion 2

    JOptionPane.showMessageDialog(null, "El apartamento Doble incluye cama matrimonial"); //Mostrar Mensaje

    if(this.opcion3){ // Condicionante si elige opcion 3

    apartamento = 6000 * 6; // Calculo de la variable apartamento

    JOptionPane.showMessageDialog(null, "Se cobrara 6,000 lps mensuales por el apartamento doble durante 6

    meses"); //Mostrar Mensaje

    }

  • 7/24/2019 Informe de Proyecto Programacin II

    20/25

    if(this.opcion4){ // Condicionante si elige opcion 4

    apartamento = 6000 * 12; // Calculo de la variable apartamento

    JOptionPane.showMessageDialog(null, "Se cobrara 6,000 lps mensuales por el apartamento doble durante 12

    meses"); //Mostrar Mensaje

    }

    if(this.si){ //Condicionante si elige si

    sp = 2000; // Calculo de la variable sp

    JOptionPane.showMessageDialog(null, "Se cobrara 2000 lps por servicio de parqueo"); // Mostrar Mensaje

    }

    if(this.no){ //Condicionante si elige no

    sp = 0; // Calculo de la variable sp

    }

    if(this.positivo){ //Condicionante si elige positivo

    sa = 2500; //Calculo de la variable sa

    JOptionPane.showMessageDialog(null, "Se cobrara 2500 lps por servicios de internet y mantenimiento de aire

    acondicionado"); // Mostrar Mensaje

    }

    if(this.negativo){ //Condicionante si elige negativo

    sa = 0; //Calculo de la variable sa

    }}

    total = apartamento + sp + sa;// Calculo de la variable "total"

    }

    public double getTotal() { // Metodo para regresar valores de la variable

    return total; // Variable a regresar

    }

    }

  • 7/24/2019 Informe de Proyecto Programacin II

    21/25

    Clase Publica salida

    package javaapplication28;

    public class salida extends javax.swing.JFrame { //Clase publica JFrame (Grafico)

    public salida() { // Creacin de constructor de la clase "salida"

    initComponents(); // Inicializacin de componentes.

    }

    public void setInicio(double total){ // Declaracin de metodo setInicio

    this.total.setText(String.valueOf(total));// Convertir variable a String para imprimir resultado

    setVisible(true); // Controla que componente sea mostrada en la siguiente pantalla

    }

    @SuppressWarnings("unchecked")

    //

    private void initComponents() {

    jLabel1 = new javax.swing.JLabel();

    jLabel4 = new javax.swing.JLabel();

    total = new javax.swing.JTextField();

    jLabel2 = new javax.swing.JLabel();

    regresar = new javax.swing.JButton();

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

  • 7/24/2019 Informe de Proyecto Programacin II

    22/25

    jLabel1.setText("Factura para rentar apartamento");

    jLabel4.setText("Total a pagar por contrato seleccionado :");

    jLabel2.setText("LPS.");

    regresar.setText("Regresar");

    regresar.addActionListener(new java.awt.event.ActionListener() {

    public void actionPerformed(java.awt.event.ActionEvent evt) {

    regresarActionPerformed(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.LEADING)

    .addGroup(layout.createSequentialGroup()

    .addGap(151, 151, 151)

    .addComponent(jLabel1))

    .addGroup(layout.createSequentialGroup()

    .addGap(23, 23, 23)

    .addComponent(jLabel4)

    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

    .addComponent(total, javax.swing.GroupLayout.PREFERRED_SIZE, 126,javax.swing.GroupLayout.PREFERRED_SIZE)

    .addGap(18, 18, 18)

    .addComponent(jLabel2)))

    .addContainerGap(72, Short.MAX_VALUE))

    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()

    .addGap(0, 0, Short.MAX_VALUE)

    .addComponent(regresar, javax.swing.GroupLayout.PREFERRED_SIZE, 115,

    javax.swing.GroupLayout.PREFERRED_SIZE)

    .addGap(26, 26, 26))

  • 7/24/2019 Informe de Proyecto Programacin II

    23/25

    );

    layout.setVerticalGroup(

    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

    .addGroup(layout.createSequentialGroup()

    .addContainerGap()

    .addComponent(jLabel1)

    .addGap(93, 93, 93)

    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

    .addComponent(jLabel4)

    .addComponent(total, javax.swing.GroupLayout.PREFERRED_SIZE,

    javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

    .addComponent(jLabel2))

    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 93, Short.MAX_VALUE)

    .addComponent(regresar, javax.swing.GroupLayout.PREFERRED_SIZE, 58,

    javax.swing.GroupLayout.PREFERRED_SIZE)

    .addContainerGap())

    );

    pack();

    }//

    private void regresarActionPerformed(java.awt.event.ActionEvent evt) {

    principal objetoprincipal = new principal(); // Llamada a clase "principal"

    objetoprincipal.setSalida(); // Llamada de metodo setSalida en clase Principal para actualizar variable y mostrar

    repetitivo

    this.setVisible(false); // Controla que componente sea mostrada en la siguiente pantalla

    }

    public static void main(String args[]) {

    //

    /* 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 {

  • 7/24/2019 Informe de Proyecto Programacin II

    24/25

    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(salida.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);

    } catch (InstantiationException ex) {

    java.util.logging.Logger.getLogger(salida.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);

    } catch (IllegalAccessException ex) {

    java.util.logging.Logger.getLogger(salida.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);

    } catch (javax.swing.UnsupportedLookAndFeelException ex) {

    java.util.logging.Logger.getLogger(salida.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);

    }

    //

    java.awt.EventQueue.invokeLater(new Runnable() {

    public void run() {

    new salida().setVisible(true);

    }

    });

    }

    // Variables declaration - do not modify

    private javax.swing.JLabel jLabel1;

    private javax.swing.JLabel jLabel2;

    private javax.swing.JLabel jLabel4;

    private javax.swing.JButton regresar;

    private javax.swing.JTextField total;

    // End of variables declaration

    }

  • 7/24/2019 Informe de Proyecto Programacin II

    25/25

    Captura de pantalla clase salida