6. EJERCICIO EN CLASES: ANIDADOS
PROGRAMA QUE DETERMINA EL NIVEL DE URGENCIA CON EL CUAL SE DEBE ATENDER A UN PACIENTE
package paqhospitalanidado;
import javax.swing.JOptionPane;
/**
*
* @author PC
*/
public class jhospitalanidado extends javax.swing.JFrame {
/**
* Creates new form jhospitalanidado
*/
public jhospitalanidado() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jComboBox1 = new javax.swing.JComboBox();
jText = new javax.swing.JTextField();
jLabel4 = new javax.swing.JLabel();
jText2 = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setText("nombres del paciente");
jLabel2.setText("Estado del paciente");
jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Inconcientes", "Tiene heridas sangrantes", "Mujer embarazada", "Niños menores de 10 años", "Vomito", "Fiebre", "Fractura", "Dolor fuerte", "Demas" }));
jText.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextActionPerformed(evt);
}
});
jLabel4.setText("Identificacion del paciente");
jButton1.setText("ENVIAR");
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()
.addGap(36, 36, 36)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 146, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel1)
.addGroup(layout.createSequentialGroup()
.addGap(119, 119, 119)
.addComponent(jLabel3))
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jComboBox1, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jText)
.addComponent(jText2)))
.addGroup(layout.createSequentialGroup()
.addGap(119, 119, 119)
.addComponent(jButton1)))
.addGap(0, 57, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(20, 20, 20)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(jText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(31, 31, 31)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jText2, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 20, Short.MAX_VALUE)
.addComponent(jLabel3)
.addGap(46, 46, 46)
.addComponent(jButton1)
.addContainerGap(79, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
private void jTextActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
String paciente;
String sintomas;
Integer identificacion;
paciente=jText.getText();
sintomas=(jComboBox1.getSelectedItem().toString());
identificacion=Integer.parseInt(jText2.getText());
if(sintomas.equals("Inconcientes")
||sintomas.equals("Tiene heridas sangrantes")
||sintomas.equals("Mujer embarazada")
||sintomas.equals("Niños menores de 10 años"))
{
JOptionPane.showMessageDialog(null,paciente+ " identificado con el documento "+identificacion+" debe ser trasladado al triage del Nivel I");
}
else
{
if(sintomas.equals("Vomito")
||sintomas.equals("Fiebre")
||sintomas.equals("Fractura")
||sintomas.equals("Dolor fuerte"))
{
JOptionPane.showMessageDialog(null,paciente+" debe ser trasladado al triage del Nivel II");
}
else
{
JOptionPane.showMessageDialog(null,paciente+" debe ser trasladado al triage del Nivel III");
}
}
// TODO add your handling code here:
}
/**
* @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) {
java.util.logging.Logger.getLogger(jhospitalanidado.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(jhospitalanidado.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(jhospitalanidado.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(jhospitalanidado.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 jhospitalanidado().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JComboBox jComboBox1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JTextField jText;
private javax.swing.JTextField jText2;
// End of variables declaration
}
2.Comprimido del programa
Anidado según el nivel de urgencia
No hay comentarios:
Publicar un comentario