Tarea33 PDF
Tarea33 PDF
Tarea33 PDF
IMPUNIDAD”
INTEGRANTES:
CURSO:
Programación Visual ll
Actividad:
Caso Problema de Unidad 01
CASO PROBLEMA:
Una tienda comercial desea registrar los distintos artefactos eléctricos indicando el nombre del
artefacto, la categoría del artefacto (audio, video o línea blanca), el stock, el precio y el modelo
del artefacto. También se desea registrar las ventas de artefactos indicando la fecha de venta y
el nombre del cliente que compró el artefacto. El cliente puede adquirir cualquier artefacto al
contado o al crédito. Si es al contado se aplica un descuento del 6% si es audio, 8% si es video y
9% si es línea blanca. Si la adquisición es al crédito se aplica un incremento del 10% si es audio,
12% si es video y 15% si es línea blanca. Después de presentarles el caso problema cada
estudiante deberá rea realizar lo siguiente:
• Crea las clases necesarias para ser luego ser usados en la programación visual.
• Diseña los formularios del caso de estudio aplicando los objetos de control básicos y los
objetos aprendidos en la I unidad de aprendizaje del curso. Debes considerar el manejo de los
distintos formas de crear formularios (JFrame, InternalFrame, JDialog,etc.)
Clases
Caso Problema l
package casoproblemai;
import controlador.CtrlPrincipal;
import modelo.Artefacto;
import vista.Form_Principal;
ctrlPrincipal.iniciar();
ControlPrincipal
package controlador;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import modelo.Artefacto;
import modelo.PersonalizarTabla;
import vista.Form_Principal;
/**
* @author decodem
*/
this.miPrincipal = miPrincipal;
this.miArtefacto = miArtefacto;
}
this.miPrincipal.setResizable(false);
this.miPrincipal.setLocationRelativeTo(null);
this.miPrincipal.setVisible(true);
this.miPrincipal.botonRegistrar.addActionListener(this);
this.miPrincipal.botonCerrar.addActionListener(this);
this.miPrincipal.botonVenta.addActionListener(this);
this.miPrincipal.opcionSeleccionarArtefacto.addActionListener(this);
PersonalizarTabla.titulosTabla(titulos, modeloTablaArtefactos,
miPrincipal.tablaListaArtefactos);
cargarFecha();
@Override
if (comando.equals("Registrar")) {
if (camposCompletos()) {
} else {
setDatosArtefacto();
resetCampos();
PersonalizarTabla.cargarDatosTabla(miPrincipal.tablaListaArtefactos,
modeloTablaArtefactos, listaArtefactos);
System.out.println("-------------------------");
} else {
/*---------------------------------------------------------*/
/*---------------------------------------------------------*/
int codigoArtefacto = Integer.parseInt((String)
this.miPrincipal.tablaListaArtefactos.getValueAt(fila, 0));
} else {
if (this.miPrincipal.radioContado.isSelected()) {
if (categoriaArtefacto.equals("Audio")) {
} else if (categoriaArtefacto.equals("Video")) {
} else {
descuento = 0.0;
if (categoriaArtefacto.equals("Audio")) {
} else if (categoriaArtefacto.equals("Video")) {
} else {
incremento = 0.0;
resultado += "\n-------------------------------------";
resultado += "\n----------------------------------------------------------------";
resultado += "\n----------------------------------------------------------------";
this.miPrincipal.areaResulatdos.setText(resultado);
descontarStockArtefacto(codigoArtefacto, cantidadLlevar, stockArtefacto);
} else if (comando.equals("Cerrar")) {
System.out.println("" + miItemArtefacto.getNombre());
|| this.miPrincipal.cajaModelo.getText().isEmpty()
|| this.miPrincipal.cajaPrecio.getText().isEmpty();
return verifica;
this.miPrincipal.cajaNombre.setText("");
this.miPrincipal.comboCategoria.setSelectedIndex(0);
this.miPrincipal.spinnerStock.setValue(1);
this.miPrincipal.cajaPrecio.setText("");
this.miPrincipal.cajaModelo.setText("");
this.miPrincipal.cajaFecha.setText(fecha);
Artefacto
package modelo;
/**
* @author decodem
*/
public Artefacto() {
public Artefacto(int codigo, String nombre, String categoria, int stock, double precio, String
modelo) {
this.codigo = codigo;
this.nombre = nombre;
this.categoria = categoria;
this.stock = stock -1 ;
this.precio = precio;
this.modelo = modelo;
return codigo;
}
this.codigo = codigo;
return nombre;
this.nombre = nombre;
return categoria;
this.categoria = categoria;
return stock;
this.stock = stock;
this.precio = precio;
return modelo;
this.modelo = modelo;
Framework Principal
Casol
import javax.swing.JOptionPane;
/**
* @author Decodem
*/
public Form_Principal() {
initComponents();
}
@SuppressWarnings("unchecked")
opcionSeleccionarArtefacto.setText("Seleccionar a Comprar");
opcionSeleccionarArtefacto.addActionListener(new java.awt.event.ActionListener() {
opcionSeleccionarArtefactoActionPerformed(evt);
});
popupMenuOpcion.add(opcionSeleccionarArtefacto);
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
botonCerrar.setText("Cerrar");
botonCerrar.addActionListener(new java.awt.event.ActionListener() {
botonCerrarActionPerformed(evt);
});
botonRegistrar.setText("Registrar");
botonRegistrar.addActionListener(new java.awt.event.ActionListener() {
botonRegistrarActionPerformed(evt);
}
});
jLabel9.setText("Modelo :");
jLabel10.setText("Precio :");
jLabel11.setText("Stock :");
jLabel12.setText("Categoria :");
jLabel13.setText("Nombre : ");
jLabel1.setText("REGISTRO DE ARTEFACTO");
jSeparator1.setOrientation(javax.swing.SwingConstants.VERTICAL);
jLabel8.setText("Cliente :");
cajaFecha.setEditable(false);
jLabel7.setText("Fecha :");
jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Listado de Artefactos"));
tablaListaArtefactos.setModel(new javax.swing.table.DefaultTableModel(
},
new String [] {
));
tablaListaArtefactos.setComponentPopupMenu(popupMenuOpcion);
jScrollPane1.setViewportView(tablaListaArtefactos);
javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
jPanel3.setLayout(jPanel3Layout);
jPanel3Layout.setHorizontalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addContainerGap()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel3Layout.setVerticalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel3Layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
botonVenta.setText("Registrar Venta");
jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder("Resultados"));
areaResulatdos.setEditable(false);
areaResulatdos.setColumns(20);
areaResulatdos.setLineWrap(true);
areaResulatdos.setRows(5);
jScrollPane2.setViewportView(areaResulatdos);
javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
jPanel5.setLayout(jPanel5Layout);
jPanel5Layout.setHorizontalGroup(
jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel5Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane2)
.addContainerGap())
);
jPanel5Layout.setVerticalGroup(
jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel5Layout.createSequentialGroup()
.addContainerGap()
.addContainerGap())
);
jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
buttonGroup1.add(radioContado);
radioContado.setSelected(true);
radioContado.setText("Contado");
buttonGroup1.add(radioCredito);
radioCredito.setText("Credito");
jLabel3.setFont(new java.awt.Font("Times New Roman", 0, 12)); // NOI18N
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
false)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel13)
.addComponent(cajaNombre, javax.swing.GroupLayout.PREFERRED_SIZE,
119, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel12)
.addComponent(jLabel11)
.addComponent(jLabel10)
.addComponent(jLabel9))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(comboCategoria, 0,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(spinnerStock)
.addComponent(cajaPrecio)
.addComponent(cajaModelo, javax.swing.GroupLayout.PREFERRED_SIZE,
122, javax.swing.GroupLayout.PREFERRED_SIZE)))))
.addGroup(layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel3)
.addComponent(radioContado)
.addComponent(radioCredito)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel7)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel8)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(botonVenta, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap())))))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel1)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel13)
.addComponent(cajaNombre,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel12)
.addComponent(comboCategoria,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jLabel11)
.addGap(6, 6, 6))
.addComponent(spinnerStock,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cajaPrecio, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel10)))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel9)
.addComponent(cajaModelo, 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(botonCerrar, javax.swing.GroupLayout.PREFERRED_SIZE,
47, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(botonRegistrar,
javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel2)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel7)
.addComponent(cajaFecha, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel8)
.addComponent(cajaCliente, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(radioCredito)
.addComponent(radioContado)
.addComponent(jLabel3))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(botonVenta)
.addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addContainerGap()
.addComponent(jSeparator1)))
.addContainerGap())
);
pack();
}// </editor-fold>
System.exit(0);
try {
if ("Metal".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
java.util.logging.Logger.getLogger(Form_Principal.class.getName()).log(java.util.logging.Level.S
EVERE, null, ex);
java.util.logging.Logger.getLogger(Form_Principal.class.getName()).log(java.util.logging.Level.S
EVERE, null, ex);
java.util.logging.Logger.getLogger(Form_Principal.class.getName()).log(java.util.logging.Level.S
EVERE, null, ex);
java.util.logging.Logger.getLogger(Form_Principal.class.getName()).log(java.util.logging.Level.S
EVERE, null, ex);
java.awt.EventQueue.invokeLater(new Runnable() {
new Form_Principal().setVisible(true);
});