Created
September 26, 2016 07:13
-
-
Save godie007/9ed5e684e2eac149c5b3ffc819699d5f to your computer and use it in GitHub Desktop.
Ejemplo de Simulación de un SuperMercado utilizando 3 colas y se aplica condicion de ingreso utiliza interfaz grafica netbeans
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* To change this license header, choose License Headers in Project Properties. | |
* To change this template file, choose Tools | Templates | |
* and open the template in the editor. | |
*/ | |
package tiendacola; | |
/** | |
* | |
* @author godie007 | |
*/ | |
public class Cliente { | |
public String nombre; | |
public int edad; | |
public float valorApagar; | |
/** | |
* Metodo Constructor | |
* | |
* @param nombre | |
* @param edad | |
* @param valorApagar | |
*/ | |
public Cliente(String nombre, int edad, float valorApagar) { | |
this.nombre = nombre; | |
this.edad = edad; | |
this.valorApagar = valorApagar; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* To change this license header, choose License Headers in Project Properties. | |
* To change this template file, choose Tools | Templates | |
* and open the template in the editor. | |
*/ | |
package tiendacola; | |
import javax.swing.JList; | |
/** | |
* | |
* @author godie007 | |
*/ | |
public class Cola { | |
private Nodo raiz; | |
/** | |
* Metodo para mostrar en una lista los nodos de una cola | |
* | |
* @param lista | |
*/ | |
public void mostrar(JList lista) { | |
Nodo temporal = raiz; | |
String[] strings = new String[10]; | |
int contado = 0; | |
while (temporal != null) { | |
strings[contado] = temporal.info.nombre + "(" + temporal.info.valorApagar + ")"; | |
contado++; | |
temporal = temporal.siguiente; | |
} | |
lista.setModel(new javax.swing.AbstractListModel() { | |
@Override | |
public int getSize() { | |
return strings.length; | |
} | |
@Override | |
public Object getElementAt(int i) { | |
return strings[i]; | |
} | |
}); | |
} | |
/** | |
* Metodo para comparar si la cola esta vacia | |
* | |
* @return | |
*/ | |
public boolean vacia() { | |
return raiz == null; | |
} | |
/** | |
* Metodo para ingresar elementos en una cola | |
* | |
* @param info | |
*/ | |
public void insertar(Cliente info) { | |
Nodo nuevo = new Nodo(info); | |
if (vacia()) { | |
raiz = nuevo; | |
} else { | |
Nodo temporal = raiz; | |
while (temporal.siguiente != null) { | |
temporal = temporal.siguiente; | |
} | |
temporal.siguiente = nuevo; | |
} | |
} | |
/** | |
* Metodo para quitar elementos de la cola | |
* | |
* @return | |
*/ | |
public boolean extraer() { | |
if (!vacia()) { | |
raiz = raiz.siguiente; | |
return true; | |
} else { | |
return false; | |
} | |
} | |
/** | |
* Metodo para contar el numero de elementos de la cola | |
* | |
* @return | |
*/ | |
public int contar() { | |
Nodo temporal = raiz; | |
int contar = 0; | |
while (temporal != null) { | |
contar++; | |
temporal = temporal.siguiente; | |
} | |
return contar; | |
} | |
/** | |
* Metodo para sumar el saldo acomulado | |
* | |
* @return | |
*/ | |
public float saldo() { | |
Nodo temporal = raiz; | |
float saldo = 0; | |
while (temporal != null) { | |
saldo += temporal.info.valorApagar; | |
temporal = temporal.siguiente; | |
} | |
return saldo; | |
} | |
/** | |
* Clase Nodo para la Cola Enlazada | |
*/ | |
public static class Nodo { | |
Cliente info; | |
Nodo siguiente; | |
public Nodo(Cliente info) { | |
this.info = info; | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* To change this license header, choose License Headers in Project Properties. | |
* To change this template file, choose Tools | Templates | |
* and open the template in the editor. | |
*/ | |
package tiendacola; | |
import javax.swing.JLabel; | |
import javax.swing.JList; | |
/** | |
* | |
* @author godie007 | |
*/ | |
public final class Supermercado { | |
private final Cola colaClientes1 = new Cola(); | |
private final Cola colaClientes2 = new Cola(); | |
private final Cola colaClientes3 = new Cola();//cola de clientes mayores | |
private int contadorAtendidos1; | |
private int contadorAtendidos2; | |
private int contadorAtendidos3; | |
public Supermercado() { | |
contadorAtendidos1 = 0; | |
contadorAtendidos2 = 0; | |
contadorAtendidos3 = 0; | |
} | |
public void imprimir(JList jlist1, JList jlist2, JList jlist3) { | |
colaClientes1.mostrar(jlist1); | |
colaClientes2.mostrar(jlist2); | |
colaClientes3.mostrar(jlist3); | |
} | |
public void atender1(JLabel atendidos) { | |
if (colaClientes1.extraer()) { | |
contadorAtendidos1++; | |
} | |
atendidos.setText("" + contadorAtendidos1); | |
} | |
public void atender2(JLabel atendidos) { | |
if (colaClientes2.extraer()) { | |
contadorAtendidos2++; | |
} | |
atendidos.setText("" + contadorAtendidos2); | |
} | |
public void atender3(JLabel atendidos) { | |
if (colaClientes3.extraer()) { | |
contadorAtendidos3++; | |
} | |
atendidos.setText("" + contadorAtendidos3); | |
} | |
public float calcularSaldo() { | |
return colaClientes1.saldo() + colaClientes2.saldo() + colaClientes3.saldo(); | |
} | |
/** | |
* Metodo para personalizar el ingreso de clientes a las colas del mercado | |
* | |
* @param cliente | |
*/ | |
public void ingresarCliente(Cliente cliente) { | |
if (colaClientes1.contar() > 7 && colaClientes2.contar() > 7 && colaClientes3.contar() == 0) { | |
colaClientes3.insertar(cliente); | |
System.out.println("Se ingreso al 3"); | |
} else { | |
if (colaClientes1.contar() <= colaClientes2.contar()) { | |
colaClientes1.insertar(cliente); | |
System.out.println("Se ingreso al 1"); | |
} else { | |
colaClientes2.insertar(cliente); | |
System.out.println("Se ingreso al 2"); | |
} | |
} | |
} | |
void mostrarCuentas(JLabel jLnumero1, JLabel jLnumero2, JLabel jLnumero3) { | |
jLnumero1.setText("" + colaClientes1.contar()); | |
jLnumero2.setText("" + colaClientes2.contar()); | |
jLnumero3.setText("" + colaClientes3.contar()); | |
} | |
void mostrarSaldos(JLabel saldo1, JLabel saldo2, JLabel saldo3) { | |
saldo1.setText("" + colaClientes1.saldo()); | |
saldo2.setText("" + colaClientes2.saldo()); | |
saldo3.setText("" + colaClientes3.saldo()); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* To change this license header, choose License Headers in Project Properties. | |
* To change this template file, choose Tools | Templates | |
* and open the template in the editor. | |
*/ | |
package tiendacola; | |
import java.awt.event.KeyEvent; | |
/** | |
* | |
* @author godie007 | |
*/ | |
public class Ventana extends javax.swing.JFrame { | |
private Supermercado tienda; | |
/** | |
* Creates new form Ventana | |
*/ | |
public Ventana() { | |
initComponents(); | |
tienda = new Supermercado(); | |
} | |
/** | |
* 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() { | |
VentanaCliente = new javax.swing.JFrame(); | |
jPanel2 = new javax.swing.JPanel(); | |
jLabel1 = new javax.swing.JLabel(); | |
jTnombre = new javax.swing.JTextField(); | |
jLabel2 = new javax.swing.JLabel(); | |
jTedad = new javax.swing.JTextField(); | |
jButton1 = new javax.swing.JButton(); | |
jLabel6 = new javax.swing.JLabel(); | |
jTvalor = new javax.swing.JTextField(); | |
jPanel1 = new javax.swing.JPanel(); | |
jScrollPane1 = new javax.swing.JScrollPane(); | |
jList1 = new javax.swing.JList(); | |
jScrollPane2 = new javax.swing.JScrollPane(); | |
jList2 = new javax.swing.JList(); | |
jScrollPane3 = new javax.swing.JScrollPane(); | |
jList3 = new javax.swing.JList(); | |
jLabel3 = new javax.swing.JLabel(); | |
jLabel4 = new javax.swing.JLabel(); | |
jLabel5 = new javax.swing.JLabel(); | |
jButton2 = new javax.swing.JButton(); | |
jLabel7 = new javax.swing.JLabel(); | |
jLsaldo = new javax.swing.JLabel(); | |
jLabel8 = new javax.swing.JLabel(); | |
jLabel9 = new javax.swing.JLabel(); | |
jLabel10 = new javax.swing.JLabel(); | |
jLnumero1 = new javax.swing.JLabel(); | |
jLnumero2 = new javax.swing.JLabel(); | |
jLnumero3 = new javax.swing.JLabel(); | |
jLabel11 = new javax.swing.JLabel(); | |
jLabel12 = new javax.swing.JLabel(); | |
jLabel13 = new javax.swing.JLabel(); | |
jLsaldo0 = new javax.swing.JLabel(); | |
jLsaldo1 = new javax.swing.JLabel(); | |
jLsaldo2 = new javax.swing.JLabel(); | |
jButton3 = new javax.swing.JButton(); | |
jButton4 = new javax.swing.JButton(); | |
jButton5 = new javax.swing.JButton(); | |
jLabel14 = new javax.swing.JLabel(); | |
jLabel15 = new javax.swing.JLabel(); | |
jLabel16 = new javax.swing.JLabel(); | |
jLatendidos0 = new javax.swing.JLabel(); | |
jLatendidos1 = new javax.swing.JLabel(); | |
jLatendidos2 = new javax.swing.JLabel(); | |
jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Ingresar Cliente")); | |
jLabel1.setText("Nombre"); | |
jLabel2.setText("Edad"); | |
jTedad.setText("0"); | |
jTedad.addKeyListener(new java.awt.event.KeyAdapter() { | |
public void keyTyped(java.awt.event.KeyEvent evt) { | |
jTedadKeyTyped(evt); | |
} | |
public void keyPressed(java.awt.event.KeyEvent evt) { | |
jTedadKeyPressed(evt); | |
} | |
}); | |
jButton1.setText("IngresarCliente"); | |
jButton1.addActionListener(new java.awt.event.ActionListener() { | |
public void actionPerformed(java.awt.event.ActionEvent evt) { | |
jButton1ActionPerformed(evt); | |
} | |
}); | |
jLabel6.setText("Valor a Pagar"); | |
jTvalor.setText("0"); | |
jTvalor.addActionListener(new java.awt.event.ActionListener() { | |
public void actionPerformed(java.awt.event.ActionEvent evt) { | |
jTvalorActionPerformed(evt); | |
} | |
}); | |
jTvalor.addKeyListener(new java.awt.event.KeyAdapter() { | |
public void keyTyped(java.awt.event.KeyEvent evt) { | |
jTvalorKeyTyped(evt); | |
} | |
public void keyPressed(java.awt.event.KeyEvent evt) { | |
jTvalorKeyPressed(evt); | |
} | |
}); | |
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); | |
jPanel2.setLayout(jPanel2Layout); | |
jPanel2Layout.setHorizontalGroup( | |
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | |
.addGroup(jPanel2Layout.createSequentialGroup() | |
.addContainerGap() | |
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) | |
.addComponent(jLabel1) | |
.addComponent(jTnombre) | |
.addComponent(jLabel2) | |
.addComponent(jTedad) | |
.addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, 255, Short.MAX_VALUE) | |
.addComponent(jLabel6) | |
.addComponent(jTvalor)) | |
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) | |
); | |
jPanel2Layout.setVerticalGroup( | |
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | |
.addGroup(jPanel2Layout.createSequentialGroup() | |
.addContainerGap() | |
.addComponent(jLabel1) | |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) | |
.addComponent(jTnombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) | |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) | |
.addComponent(jLabel2) | |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) | |
.addComponent(jTedad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) | |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) | |
.addComponent(jLabel6) | |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) | |
.addComponent(jTvalor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) | |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) | |
.addComponent(jButton1) | |
.addGap(62, 62, 62)) | |
); | |
javax.swing.GroupLayout VentanaClienteLayout = new javax.swing.GroupLayout(VentanaCliente.getContentPane()); | |
VentanaCliente.getContentPane().setLayout(VentanaClienteLayout); | |
VentanaClienteLayout.setHorizontalGroup( | |
VentanaClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | |
.addGroup(VentanaClienteLayout.createSequentialGroup() | |
.addContainerGap() | |
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) | |
.addContainerGap(22, Short.MAX_VALUE)) | |
); | |
VentanaClienteLayout.setVerticalGroup( | |
VentanaClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | |
.addGroup(VentanaClienteLayout.createSequentialGroup() | |
.addContainerGap() | |
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 261, javax.swing.GroupLayout.PREFERRED_SIZE) | |
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) | |
); | |
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); | |
jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder()); | |
jList1.setModel(new javax.swing.AbstractListModel() { | |
String[] strings = { "" }; | |
public int getSize() { return strings.length; } | |
public Object getElementAt(int i) { return strings[i]; } | |
}); | |
jScrollPane1.setViewportView(jList1); | |
jList2.setModel(new javax.swing.AbstractListModel() { | |
String[] strings = { "" }; | |
public int getSize() { return strings.length; } | |
public Object getElementAt(int i) { return strings[i]; } | |
}); | |
jScrollPane2.setViewportView(jList2); | |
jList3.setModel(new javax.swing.AbstractListModel() { | |
String[] strings = { "" }; | |
public int getSize() { return strings.length; } | |
public Object getElementAt(int i) { return strings[i]; } | |
}); | |
jScrollPane3.setViewportView(jList3); | |
jLabel3.setText("Cola 1"); | |
jLabel4.setText("Cola 2"); | |
jLabel5.setText("Cola Adultos Mayores"); | |
jButton2.setText("IngresarCliente"); | |
jButton2.addActionListener(new java.awt.event.ActionListener() { | |
public void actionPerformed(java.awt.event.ActionEvent evt) { | |
jButton2ActionPerformed(evt); | |
} | |
}); | |
jLabel7.setText("Saldo Total"); | |
jLsaldo.setText("$0"); | |
jLabel8.setText("Clientes:"); | |
jLabel9.setText("Clientes:"); | |
jLabel10.setText("Clientes:"); | |
jLnumero1.setText("0"); | |
jLnumero2.setText("0"); | |
jLnumero3.setText("0"); | |
jLabel11.setText("Saldo:"); | |
jLabel12.setText("Saldo:"); | |
jLabel13.setText("Saldo:"); | |
jLsaldo0.setText("$0"); | |
jLsaldo1.setText("$0"); | |
jLsaldo2.setText("$0"); | |
jButton3.setText("Atender"); | |
jButton3.addActionListener(new java.awt.event.ActionListener() { | |
public void actionPerformed(java.awt.event.ActionEvent evt) { | |
jButton3ActionPerformed(evt); | |
} | |
}); | |
jButton4.setText("Atender"); | |
jButton4.addActionListener(new java.awt.event.ActionListener() { | |
public void actionPerformed(java.awt.event.ActionEvent evt) { | |
jButton4ActionPerformed(evt); | |
} | |
}); | |
jButton5.setText("Atender"); | |
jButton5.addActionListener(new java.awt.event.ActionListener() { | |
public void actionPerformed(java.awt.event.ActionEvent evt) { | |
jButton5ActionPerformed(evt); | |
} | |
}); | |
jLabel14.setText("Atendidos:"); | |
jLabel15.setText("Atendidos:"); | |
jLabel16.setText("Atendidos:"); | |
jLatendidos0.setText("0"); | |
jLatendidos1.setText("0"); | |
jLatendidos2.setText("0"); | |
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); | |
jPanel1.setLayout(jPanel1Layout); | |
jPanel1Layout.setHorizontalGroup( | |
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | |
.addGroup(jPanel1Layout.createSequentialGroup() | |
.addContainerGap() | |
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | |
.addComponent(jButton2) | |
.addComponent(jLabel7) | |
.addComponent(jLsaldo)) | |
.addGap(18, 18, 18) | |
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | |
.addComponent(jLabel3) | |
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 157, javax.swing.GroupLayout.PREFERRED_SIZE) | |
.addGroup(jPanel1Layout.createSequentialGroup() | |
.addComponent(jLabel8) | |
.addGap(4, 4, 4) | |
.addComponent(jLnumero1)) | |
.addGroup(jPanel1Layout.createSequentialGroup() | |
.addComponent(jLabel12) | |
.addGap(4, 4, 4) | |
.addComponent(jLsaldo0)) | |
.addGroup(jPanel1Layout.createSequentialGroup() | |
.addComponent(jLabel14) | |
.addGap(2, 2, 2) | |
.addComponent(jLatendidos0)) | |
.addComponent(jButton3)) | |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) | |
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | |
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 161, javax.swing.GroupLayout.PREFERRED_SIZE) | |
.addComponent(jLabel4) | |
.addGroup(jPanel1Layout.createSequentialGroup() | |
.addComponent(jLabel9) | |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) | |
.addComponent(jLnumero2)) | |
.addGroup(jPanel1Layout.createSequentialGroup() | |
.addComponent(jLabel13) | |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) | |
.addComponent(jLsaldo1)) | |
.addGroup(jPanel1Layout.createSequentialGroup() | |
.addComponent(jLabel15) | |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) | |
.addComponent(jLatendidos1)) | |
.addComponent(jButton4)) | |
.addGap(31, 31, 31) | |
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | |
.addComponent(jButton5) | |
.addGroup(jPanel1Layout.createSequentialGroup() | |
.addComponent(jLabel11) | |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) | |
.addComponent(jLsaldo2)) | |
.addGroup(jPanel1Layout.createSequentialGroup() | |
.addComponent(jLabel10) | |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) | |
.addComponent(jLnumero3)) | |
.addComponent(jLabel5) | |
.addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 172, javax.swing.GroupLayout.PREFERRED_SIZE) | |
.addGroup(jPanel1Layout.createSequentialGroup() | |
.addComponent(jLabel16) | |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) | |
.addComponent(jLatendidos2))) | |
.addContainerGap(27, Short.MAX_VALUE)) | |
); | |
jPanel1Layout.setVerticalGroup( | |
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | |
.addGroup(jPanel1Layout.createSequentialGroup() | |
.addContainerGap() | |
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | |
.addGroup(jPanel1Layout.createSequentialGroup() | |
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) | |
.addComponent(jLabel3) | |
.addComponent(jLabel4) | |
.addComponent(jLabel5)) | |
.addGap(1, 1, 1) | |
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) | |
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 194, Short.MAX_VALUE) | |
.addComponent(jScrollPane2) | |
.addComponent(jScrollPane3)) | |
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) | |
.addComponent(jLabel8) | |
.addComponent(jLabel9) | |
.addComponent(jLnumero1) | |
.addComponent(jLnumero2) | |
.addComponent(jLabel10) | |
.addComponent(jLnumero3))) | |
.addGroup(jPanel1Layout.createSequentialGroup() | |
.addComponent(jButton2) | |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) | |
.addComponent(jLabel7) | |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) | |
.addComponent(jLsaldo))) | |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) | |
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | |
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) | |
.addComponent(jLabel12) | |
.addComponent(jLsaldo0)) | |
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) | |
.addComponent(jLabel11) | |
.addComponent(jLsaldo2)) | |
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) | |
.addComponent(jLabel13) | |
.addComponent(jLsaldo1))) | |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) | |
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | |
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | |
.addGroup(jPanel1Layout.createSequentialGroup() | |
.addComponent(jLabel14) | |
.addGap(7, 7, 7)) | |
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() | |
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) | |
.addComponent(jLabel15) | |
.addComponent(jLatendidos0) | |
.addComponent(jLatendidos1)) | |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))) | |
.addGroup(jPanel1Layout.createSequentialGroup() | |
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) | |
.addComponent(jLabel16) | |
.addComponent(jLatendidos2)) | |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))) | |
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | |
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) | |
.addComponent(jButton4) | |
.addComponent(jButton5)) | |
.addComponent(jButton3)) | |
.addContainerGap(45, Short.MAX_VALUE)) | |
); | |
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); | |
getContentPane().setLayout(layout); | |
layout.setHorizontalGroup( | |
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | |
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() | |
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) | |
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) | |
.addGap(103, 103, 103)) | |
); | |
layout.setVerticalGroup( | |
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | |
.addGroup(layout.createSequentialGroup() | |
.addContainerGap() | |
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) | |
.addContainerGap()) | |
); | |
pack(); | |
}// </editor-fold> | |
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) { | |
this.VentanaCliente.setVisible(true); | |
this.VentanaCliente.setSize(350, 300); | |
} | |
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { | |
tienda.ingresarCliente(new Cliente(jTnombre.getText(), Integer.parseInt(jTedad.getText()),Float.parseFloat(jTvalor.getText()))); | |
tienda.imprimir(jList1,jList2,jList3); | |
tienda.mostrarCuentas(jLnumero1,jLnumero2,jLnumero3); | |
tienda.mostrarSaldos(jLsaldo0,jLsaldo1,jLsaldo2); | |
this.VentanaCliente.setVisible(false); | |
jTnombre.setText(""); | |
jTedad.setText("0"); | |
jTvalor.setText("0"); | |
jLsaldo.setText("$"+tienda.calcularSaldo()); | |
} | |
private void jTvalorActionPerformed(java.awt.event.ActionEvent evt) { | |
// TODO add your handling code here: | |
} | |
private void jTedadKeyPressed(java.awt.event.KeyEvent evt) { | |
} | |
private void jTvalorKeyPressed(java.awt.event.KeyEvent evt) { | |
} | |
private void jTedadKeyTyped(java.awt.event.KeyEvent evt) { | |
char c = evt.getKeyChar(); | |
if (!(Character.isDigit(c) || | |
(c == KeyEvent.VK_BACK_SPACE) || | |
(c == KeyEvent.VK_DELETE))) { | |
evt.consume(); | |
} | |
} | |
private void jTvalorKeyTyped(java.awt.event.KeyEvent evt) { | |
char c = evt.getKeyChar(); | |
if (!(Character.isDigit(c) || | |
(c == KeyEvent.VK_BACK_SPACE) || | |
(c == KeyEvent.VK_DELETE))) { | |
evt.consume(); | |
} | |
} | |
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) { | |
tienda.atender1(jLatendidos0); | |
tienda.imprimir(jList1, jList2, jList3); | |
} | |
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) { | |
tienda.atender2(jLatendidos1); | |
tienda.imprimir(jList1, jList2, jList3); | |
} | |
private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) { | |
tienda.atender3(jLatendidos2); | |
tienda.imprimir(jList1, jList2, jList3); | |
} | |
/** | |
* @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(Ventana.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); | |
} catch (InstantiationException ex) { | |
java.util.logging.Logger.getLogger(Ventana.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); | |
} catch (IllegalAccessException ex) { | |
java.util.logging.Logger.getLogger(Ventana.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); | |
} catch (javax.swing.UnsupportedLookAndFeelException ex) { | |
java.util.logging.Logger.getLogger(Ventana.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 Ventana().setVisible(true); | |
} | |
}); | |
} | |
// Variables declaration - do not modify | |
private javax.swing.JFrame VentanaCliente; | |
private javax.swing.JButton jButton1; | |
private javax.swing.JButton jButton2; | |
private javax.swing.JButton jButton3; | |
private javax.swing.JButton jButton4; | |
private javax.swing.JButton jButton5; | |
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 jLabel15; | |
private javax.swing.JLabel jLabel16; | |
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.JLabel jLabel8; | |
private javax.swing.JLabel jLabel9; | |
private javax.swing.JLabel jLatendidos0; | |
private javax.swing.JLabel jLatendidos1; | |
private javax.swing.JLabel jLatendidos2; | |
private javax.swing.JList jList1; | |
private javax.swing.JList jList2; | |
private javax.swing.JList jList3; | |
private javax.swing.JLabel jLnumero1; | |
private javax.swing.JLabel jLnumero2; | |
private javax.swing.JLabel jLnumero3; | |
private javax.swing.JLabel jLsaldo; | |
private javax.swing.JLabel jLsaldo0; | |
private javax.swing.JLabel jLsaldo1; | |
private javax.swing.JLabel jLsaldo2; | |
private javax.swing.JPanel jPanel1; | |
private javax.swing.JPanel jPanel2; | |
private javax.swing.JScrollPane jScrollPane1; | |
private javax.swing.JScrollPane jScrollPane2; | |
private javax.swing.JScrollPane jScrollPane3; | |
private javax.swing.JTextField jTedad; | |
private javax.swing.JTextField jTnombre; | |
private javax.swing.JTextField jTvalor; | |
// End of variables declaration | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment