Está en la página 1de 9

Proyecto en Netbeans

¿CUÁL ES EL DISEÑO DEL PROGRAMA?


En este proyecto se utilizaron los siguientes objetos:
 JRADIO BUTTON
 JCOMBOBOX
 JTABLE
 JTEXTFIELD
 JLABEL
 JBUTTON

El diseño del programa es el siguiente:


¿CÓMO FUNCIONA EL PROGRAMA?
Nombres de variables utilizadas:
 opanillo
 opcollar
 opesclava
 cbingredientes
 pnombre
 papellido
 tbdatos
 total
DESCRIPCIÓN DEL PROGRAMA:
El programa fue hecho con el fin de registrar las ventas de una joyería, tomando en cuenta:
el nombre y apellido del cliente, el artículo vendido con el material correspondiente, para
concluir con el total de la venta.
Se ingresa que tipo de artículo se vende, luego se elige el material, después se ingresa el
primer nombre y el primer apellido. Para calcular el total del producto, se debe dar clic en
el botón “Calcular” que posee el siguiente código:
int valor=0,precio=0,tot=0;
String opcion="";

opcion = cbingredientes.getSelectedItem().toString();
if(opcion.equals("Plata")){
valor=valor+15;
}
if(opcion.equals("Oro")){
valor=valor+10;
}
if(opcion.equals("Bronce")){
valor=valor+5;
}

if (opanillo.isSelected()) {
precio=40;
}
if (opcollar.isSelected()) {
precio=30;
}
if (opesclava.isSelected()) {
valor=valor+50;
}
tot=valor+precio;
total.setText(String.valueOf(tot));
Para registrar la venta se debe hacer clic en el botón “Registrar” que posee el siguiente
código:
String opcion="";

opcion = cbingredientes.getSelectedItem().toString();
DefaultTableModel modelo = (DefaultTableModel)
tbdatos.getModel();
Object [] fila=new Object[6];
fila[0]=pnombre.getText();
fila[1]=papellido.getText();
if (opanillo.isSelected()) {
fila[2]="anillo";
}
if (opcollar.isSelected()) {
fila[2]="collar";
}
if (opesclava.isSelected()) {
fila[2]="esclava";
}
if(opcion.equals("Plata")){
fila[3]="Plata";
}
if(opcion.equals("Oro")){
fila[3]="Oro";
}
if(opcion.equals("Bronce")){
fila[3]="Bronce";
}

fila[4]=total.getText();
modelo.addRow(fila);

tbdatos.setModel(modelo);
Por último, para agregar un nuevo registro, haga clic en el botón “Limpiar”, su código es:
total.setText("");
pnombre.setText("");
papellido.setText("");

PROGRAMA FUNCIONANDO CON VALORES DE PRUEBA:


EL LINK DE ACCESO A LA CARPETA DEL PROGRAMA ES EL SIGUIENTE:
https://1drv.ms/u/s!AmVqISxxIi7CsE7kTTDmlfXq7YGP?e=HNO3eI

También podría gustarte