Sei sulla pagina 1di 56
PONTIFICIA UNIVERSIDAD CATÓLICA DEL ECUADOR SEDE – IBARRA Nombre: Marcos Ruales. Fecha: 19/04/17 ESCUELA DE

PONTIFICIA UNIVERSIDAD CATÓLICA DEL ECUADOR

SEDE IBARRA

Nombre: Marcos Ruales. Fecha: 19/04/17

ESCUELA DE INGENIERÍA

INTALACION DE VB Decompiler Lite.

SEDE – IBARRA Nombre: Marcos Ruales. Fecha: 19/04/17 ESCUELA DE INGENIERÍA INTALACION DE VB Decompiler Lite.

EJEMPLOS:

EJEMPLOS: VERSION 5.00 Begin VB.Form Form1 Caption = "Calculadora by marco" ScaleMode = 1 AutoRedraw =

VERSION 5.00 Begin VB.Form Form1

Caption = "Calculadora by marco" ScaleMode = 1 AutoRedraw = False FontTransparent = True BorderStyle = 4 'Fixed ToolWindow 'Icon = n/a LinkTopic = "Form1"

MaxButton = 0

'False

MinButton = 0

'False

ClientLeft = 45 ClientTop = 285 ClientWidth = 3975 ClientHeight = 3195 ShowInTaskbar = 0

StartUpPosition = 3 'Windows Default Begin CommandButton salir

'False

Caption = "Salir"

Left = 2160

Top

= 2520

Width = 1695 Height = 495 TabIndex = 11 End Begin CommandButton new Caption = "Nuevo calculo" Left = 120 Top = 2520 Width = 1695 Height = 495 TabIndex = 10 End

Begin CommandButton dividir Caption = "/"

Left = 3240

= 1800

Top

Width = 615 Height = 495 TabIndex = 9 BeginProperty Font Name = "MS Sans Serif" Size = 13,5 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False

Strikethrough = 0 'False EndProperty End Begin CommandButton por Caption = "x"

Left = 2160

Top

= 1800 Width = 615 Height = 495 TabIndex = 8 BeginProperty Font Name = "MS Sans Serif" Size = 13,5 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty End Begin CommandButton restar Caption = "-" Left = 1200 Top = 1800 Width = 615 Height = 495 TabIndex = 7 BeginProperty Font Name = "MS Sans Serif"

Size = 13,5 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty End Begin CommandButton sumar Caption = "+" Left = 120 Top = 1800 Width = 615 Height = 495 TabIndex = 6 BeginProperty Font Name = "MS Sans Serif" Size = 13,5 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty End Begin TextBox res Left = 1680 Top = 1080 Width = 1215

Height = 405 TabIndex = 5 BeginProperty Font Name = "MS Sans Serif" Size = 9,75 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty End Begin TextBox can2 Left = 1680 Top = 600 Width = 1215 Height = 405 TabIndex = 4 BeginProperty Font Name = "MS Sans Serif" Size = 9,75 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty End Begin TextBox can1

Left = 1680 Top = 120 Width = 1215 Height = 405 TabIndex = 3 BeginProperty Font Name = "MS Sans Serif" Size = 9,75 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty End Begin Label Label3 Caption = "Resultado" Left = 240 Top = 1200 Width = 1095 Height = 255 TabIndex = 2 BeginProperty Font Name = "MS Sans Serif" Size = 9,75 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False

Strikethrough = 0 'False EndProperty End Begin Label Label2 Caption = "Cantidad2"

Left = 240

= 720

Top

Width = 1095 Height = 615 TabIndex = 1 BeginProperty Font Name = "MS Sans Serif" Size = 9,75 Charset = 0

Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty End Begin Label Label1 Caption = "Cantidad1"

Left = 240

= 240

Top

Width = 1215 Height = 495 TabIndex = 0 BeginProperty Font Name = "MS Sans Serif"

Size = 9,75 Charset = 0 Weight = 700 Underline = 0 'False Strikethrough = 0 'False EndProperty End End

Italic = 0 'False

Attribute VB_Name = "Form1" EJERCICIO 2

0 'False Attribute VB_Name = "Form1" EJERCICIO 2 Public Sub .ctor() '402050 Code: TinyFormat Start:

Public Sub .ctor() '402050 Code: TinyFormat Start: 402051 Size: 23

loc_402051: ldarg.0

loc_402052:

ldnull

loc_402053: stfld

components

loc_402059: call .ctor

nop

loc_402058: ldarg.0

loc_40205E:

loc_40205F: nop

loc_402060: ldarg.0

loc_402061: call InitializeComponent

loc_402066: nop

loc_402067: ret

End Sub

JD-GUI Ejercicio 3

nop loc_402067: ret End Sub JD-GUI Ejercicio 3 package investigacionoperaciones; import java.awt.Color;

package investigacionoperaciones;

import java.awt.Color; import java.awt.Container; import java.awt.EventQueue; import java.awt.Font; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.ArrayList; import java.util.logging.Level; import java.util.logging.Logger; import

javax.swing.BorderFactory; import javax.swing.DefaultListModel; import javax.swing.GroupLayout; import javax.swing.GroupLayout.Alignment; import javax.swing.GroupLayout.ParallelGroup; import javax.swing.GroupLayout.SequentialGroup; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.JTextArea; import javax.swing.JTextField;

import javax.swing.LayoutStyle.ComponentPlacement; import javax.swing.UIManager; import javax.swing.UIManager.LookAndFeelInfo; import javax.swing.UnsupportedLookAndFeelException; import javax.swing.border.MatteBorder; import javax.swing.table.DefaultTableModel; import javax.swing.table.TableModel;

public class Ejecutar JFrame

{

extends

TableModel tableModelDatos;

TableModel tableModelDatos2;

TableModel tableModelDatos3;

public Ejecutar()

{

initComponents();

}

private void initComponents()

{

this.jScrollPane1 = new JScrollPane();

this.Tabla

= new JTable();

this.jPanel1 = new JPanel();

JLabel();

this.jLabel1 = new JLabel();

this.jLabel3 = new JLabel();

this.jLabel2 = new

this.txtNumFilas = new JTextField();

this.txtNumColumna =

new JTextField();

JButton();

this.Btn_Equilibrar = new JButton();

this.Btn_EsquinaNoroeste = new JButton(); this.BtnCostoMinimo = new JButton(); this.jScrollPane2 = new JScrollPane();

this.TablaDatos2 = new JTable();

= new JScrollPane();

JTextArea();

this.jLabel5 = new JLabel();

new JScrollPane(); JTable();

this.Btn_Generar = new

this.jPanel2 = new JPanel();

this.jScrollPane3

this.Txta_Impresion = new

this.jLabel4 = new JLabel();

this.jScrollPane4 =

this.TablaDatos3 = new

setDefaultCloseOperation(3);

this.Tabla.setModel(new DefaultTableModel(new Object[0][], new String[0]));

this.jScrollPane1.setViewportView(this.Tabla);

this.jLabel3.setFont(new Font("Times New Roman", 1, 36));

this.jLabel3.setForeground(new

Color(255, 204, 0));

this.jLabel3.setText("INVESTIGACION DE OPERACIONES");

this.jPanel1.setBorder(BorderFactory.createLineBorder(new Color(0, 0, 0)));

this.jLabel2.setFont(new Font("Times New Roman", 1, 14)); numero de ofertas :");

this.jLabel2.setText("Ingrese el

this.txtNumFilas.setFont(new Font("Times New Roman", 1, 12));

this.jLabel1.setFont(new Font("Times New Roman", 1, 14)); numero de demandas :");

this.jLabel1.setText("Ingrese el

this.txtNumColumna.setFont(new Font("Times New Roman", 1, 12));

this.Btn_Generar.setFont(new Font("Times New Roman", 1, 14)); this.Btn_Generar.setText("Crear");

this.Btn_Generar.addActionListener(new ActionListener()

{

public void actionPerformed(ActionEvent evt)

{

Ejecutar.this.Btn_GenerarActionPerformed(evt);

}

});

GroupLayout jPanel1Layout = new GroupLayout(this.jPanel1);

this.jPanel1.setLayout(jPanel1Layout);

.createParallelGroup(GroupLayout.Alignment.LEADING)

jPanel1Layout.setHorizontalGroup(jPanel1Layout

.addGroup(jPanel1Layout.createSequentialGroup()

.addContainerGap()

.addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING)

.addGroup(GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()

.addComponent(this.jLabel2)

.addGap(32, 32, 32))

.addGroup(jPanel1Layout.createSequentialGroup()

.addComponent(this.jLabel1)

.addGap(14, 14, 14)))

.addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING, false)

.addComponent(this.txtNumColumna, -1, 86, 32767)

.addComponent(this.txtNumFilas))

.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)

.addComponent(this.Btn_Generar, -2, 88, -2)

.addContainerGap(18, 32767)));

jPanel1Layout.setVerticalGroup(jPanel1Layout

.createParallelGroup(GroupLayout.Alignment.LEADING)

.addGroup(jPanel1Layout.createSequentialGroup()

.addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING)

.addGroup(jPanel1Layout.createSequentialGroup()

.addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)

.addComponent(this.jLabel2)

.addComponent(this.txtNumFilas, -2, -1, -2))

.addGap(18, 18, 18)

.addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)

.addComponent(this.jLabel1)

.addComponent(this.txtNumColumna, -2, -1, -2)))

.addGroup(jPanel1Layout.createSequentialGroup()

.addGap(20, 20, 20)

.addComponent(this.Btn_Generar, -2, 58, -2)))

.addContainerGap(29, 32767)));

this.jPanel2.setBorder(new MatteBorder(null));

this.Btn_Equilibrar.setFont(new Font("Times New Roman", 1, 14)); this.Btn_Equilibrar.setForeground(new Color(204, 0, 0)); this.Btn_Equilibrar.setText("Equilibrar");

this.Btn_Equilibrar.addActionListener(new ActionListener()

{

public void actionPerformed(ActionEvent evt) Ejecutar.this.Btn_EquilibrarActionPerformed(evt);

{

}

});

this.Btn_EsquinaNoroeste.setFont(new Font("Times New Roman", 1,

14));

this.Btn_EsquinaNoroeste.setForeground(new Color(204, 0, 0));

this.Btn_EsquinaNoroeste.setText("Esquina Noroeste"); this.Btn_EsquinaNoroeste.addActionListener(new ActionListener()

{

public void actionPerformed(ActionEvent evt)

{

Ejecutar.this.Btn_EsquinaNoroesteActionPerformed(evt);

}

});

this.BtnCostoMinimo.setFont(new Font("Times New Roman", 1, 14)); this.BtnCostoMinimo.setText("Costo Minimo");

this.BtnCostoMinimo.addActionListener(new ActionListener()

{

public void actionPerformed(ActionEvent evt)

{

Ejecutar.this.BtnCostoMinimoActionPerformed(evt);

}

});

GroupLayout jPanel2Layout = new GroupLayout(this.jPanel2);

this.jPanel2.setLayout(jPanel2Layout);

.createParallelGroup(GroupLayout.Alignment.LEADING)

jPanel2Layout.setHorizontalGroup(jPanel2Layout

.addGroup(jPanel2Layout.createSequentialGroup()

.addContainerGap()

.addComponent(this.Btn_Equilibrar)

.addGap(18, 18, 18)

.addComponent(this.Btn_EsquinaNoroeste)

.addGap(32, 32, 32)

.addComponent(this.BtnCostoMinimo)

.addContainerGap(41, 32767)));

jPanel2Layout.setVerticalGroup(jPanel2Layout

.createParallelGroup(GroupLayout.Alignment.LEADING)

.addGroup(jPanel2Layout.createSequentialGroup()

.addGap(23, 23, 23)

.addGroup(jPanel2Layout.createParallelGroup(GroupLayout.Alignment.LEADING, false)

.addComponent(this.BtnCostoMinimo, -1, 52, 32767)

.addGroup(jPanel2Layout.createParallelGroup(GroupLayout.Alignment.LEADING, false)

.addComponent(this.Btn_EsquinaNoroeste, -1, -1, 32767)

.addComponent(this.Btn_Equilibrar, -1, 52, 32767)))

.addContainerGap(36, 32767)));

this.TablaDatos2.setModel(new DefaultTableModel(new Object[0][], new String[0]));

this.jScrollPane2.setViewportView(this.TablaDatos2);

this.Txta_Impresion.setColumns(20);

this.jScrollPane3.setViewportView(this.Txta_Impresion);

this.Txta_Impresion.setRows(5);

this.jLabel4.setFont(new Font("Times New Roman", 1, 36));

this.jLabel4.setForeground(new Color(102, 255, 51));

this.jLabel4.setText("Tabla Datos ");

this.jLabel5.setFont(new Font("Times New Roman", 1, 36)); Resultados");

this.jLabel5.setText("Tabla

this.TablaDatos3.setModel(new DefaultTableModel(new Object[0][], new String[0]));

this.jScrollPane4.setViewportView(this.TablaDatos3);

GroupLayout layout = new GroupLayout(getContentPane());

getContentPane().setLayout(layout);

layout.setHorizontalGroup(layout

.createParallelGroup(GroupLayout.Alignment.LEADING)

.addGroup(layout.createSequentialGroup()

.addGap(133, 133, 133)

.addComponent(this.jLabel4)

.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, -1, 32767)

.addComponent(this.jLabel5)

.addGap(114, 114, 114))

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

.addContainerGap(-1, 32767)

.addComponent(this.jLabel3)

.addGap(138, 138, 138))

.addGroup(layout.createSequentialGroup()

.addContainerGap()

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

.addGroup(layout.createSequentialGroup()

.addComponent(this.jPanel1, -2, -1, -2)

.addGap(18, 18, 18)

.addComponent(this.jPanel2, -2, -1, -2))

.addGroup(layout.createSequentialGroup()

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

.addComponent(this.jScrollPane2, -2, 430, -2)

.addComponent(this.jScrollPane4, -2, 430, -2))

.addGap(18, 18, 18)

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

.addComponent(this.jScrollPane3, -2, 430, -2)

.addComponent(this.jScrollPane1, -2, 430, -2))))

.addContainerGap(-1, 32767)));

layout.setVerticalGroup(layout

.createParallelGroup(GroupLayout.Alignment.LEADING)

.addGroup(layout.createSequentialGroup()

.addContainerGap()

.addComponent(this.jLabel3)

.addGap(9, 9, 9)

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

.addComponent(this.jPanel2, -2, -1, -2)

.addComponent(this.jPanel1, -2, -1, -2))

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

.addGroup(layout.createSequentialGroup()

.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, -1, 32767)

.addComponent(this.jLabel5)

.addGap(10, 10, 10))

.addGroup(layout.createSequentialGroup()

.addComponent(this.jLabel4)

.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 49, 32767)))

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

.addComponent(this.jScrollPane2, GroupLayout.Alignment.TRAILING, -2, 180, -2)

.addComponent(this.jScrollPane1, GroupLayout.Alignment.TRAILING, -2, 180, -2))

.addGap(30, 30, 30)

.addGroup(layout.createParallelGroup(GroupLayout.Alignment.TRAILING)

.addComponent(this.jScrollPane3, -2, 165, -2)

.addComponent(this.jScrollPane4, -2, 165, -2))

.addContainerGap()));

pack();

}

DefaultListModel model = new DefaultListModel();

DefaultListModel modelo2 = new DefaultListModel(); DefaultListModel modelo3 = new DefaultListModel();

int columnas; sumaOferta = 0;

sumaDemanda = 0;

int

int

int filas;

ArrayList<Integer> vectorOferta;

ArrayList<Integer> vectorDemanda;

ArrayList<Integer> Demanda;

ArrayList<Integer> oferta;

Object[] auxDemanda;

Object[] auxOferta;

DefaultTableModel mitableModel;

DefaultTableModel mitableModel2;

DefaultTableModel mitableModel3;

Object[][] matriz;

false;

int auxi;

boolean rec;

int temfilas;

int auxj;

boolean temp = int temcolumnas; int sumaMinima;

private void Btn_GenerarActionPerformed(ActionEvent evt)

{ this.filas = (Integer.parseInt(this.txtNumFilas.getText()) + 2);

this.columnas =

(Integer.parseInt(this.txtNumColumna.getText()) + 2);

this.temcolumnas = this.columnas;

0;

this.temfilas = this.filas;

this.sumaDemanda =

this.sumaOferta = 0;

this.matriz = new Object[this.filas][this.columnas];

this.tableModelDatos = this.Tabla.getModel();

this.mitableModel = ((DefaultTableModel)this.Tabla.getModel());

this.mitableModel.setNumRows(this.filas);

this.mitableModel.setColumnCount(this.columnas);

cont = 1;

this.vectorDemanda = new ArrayList();

ArrayList();

int

this.vectorOferta = new ArrayList();

this.oferta = new

this.Demanda = new ArrayList();

this.model.clear();

this.auxDemanda = new Object[this.columnas - 1];

Object[this.filas - 1];

this.TablaDatos2.getModel();

this.tableModelDatos2 =

this.auxOferta = new

this.mitableModel2 = ((DefaultTableModel)this.TablaDatos2.getModel());

this.modelo2.clear();

this.mitableModel2.setNumRows(this.filas);

this.mitableModel2.setColumnCount(this.columnas);

this.tableModelDatos3 = this.TablaDatos3.getModel();

this.mitableModel3 = ((DefaultTableModel)this.TablaDatos3.getModel());

this.modelo3.clear();

this.mitableModel3.setNumRows(this.filas);

this.mitableModel3.setColumnCount(this.columnas);

0; i < this.filas; i++)

{

for (int i =

for (int j = 0; j < this.columnas - 1; j++) {

if (i == 0)

this.tableModelDatos.setValueAt("Pers " + (j + 1), i, j + 1); this.tableModelDatos2.setValueAt("Pers " + (j + 1), i, j + 1); this.tableModelDatos3.setValueAt("Pers " + (j + 1), i, j + 1);

1)] = ("Pers " + (j + 1));

if (j == this.columnas - 2)

{

{

this.matriz[i][(j +

this.tableModelDatos.setValueAt("OFERTA ", i, j + 1); this.tableModelDatos2.setValueAt("OFERTA ", i, j + 1); this.tableModelDatos3.setValueAt("OFERTA ", i, j + 1);

} }

this.matriz[i][(j + 1)] = "OFERTA ";

else if (j == 0)

{ this.tableModelDatos.setValueAt("Suc " + i, i, j);

this.tableModelDatos2.setValueAt("Suc " + i, i, j);

this.tableModelDatos3.setValueAt("Suc " + i, i, j);

= ("Suc " + i);

if (i == this.filas - 1)

this.matriz[i][j]

{

this.tableModelDatos.setValueAt("DEMANDA ", i, j); this.tableModelDatos2.setValueAt("DEMANDA ", i, j); this.tableModelDatos3.setValueAt("DEMANDA ", i, j);

} }

this.matriz[i][j] = "DEMANDA ";

else if (i <= this.filas - 2)

{

int num = (int)(Math.random() * 11.0D + 5.0D);

this.tableModelDatos.setValueAt(Integer.valueOf(num), i, j); this.tableModelDatos2.setValueAt(Integer.valueOf(num), i, j); this.tableModelDatos3.setValueAt(Integer.valueOf(num), i, j); Integer.valueOf(num);

}

else if (i == this.filas - 1)

{

this.matriz[i][j] =

int num3 = (int)(Math.random() * 18.0D + 100.0D); this.tableModelDatos.setValueAt(Integer.valueOf(num3), i, j); this.tableModelDatos2.setValueAt(Integer.valueOf(num3), i, j); this.tableModelDatos3.setValueAt(Integer.valueOf(num3), i, j);

this.vectorDemanda.add(Integer.valueOf(num3));

this.Demanda.add(Integer.valueOf(num3));

Integer.valueOf(num3);

this.auxDemanda[j] =

this.sumaDemanda += num3;

this.matriz[i][j] = Integer.valueOf(num3);

}

}

int num3 = (int)(Math.random() * 31.0D + 120.0D); this.filas - 2)

if (i <

 

{

 

this.tableModelDatos.setValueAt(Integer.valueOf(num3), cont, this.columnas -

1);

 

this.tableModelDatos2.setValueAt(Integer.valueOf(num3), cont, this.columnas -

1);

 

this.tableModelDatos3.setValueAt(Integer.valueOf(num3), cont, this.columnas -

1);

 

this.matriz[cont][(this.columnas - 1)] = Integer.valueOf(num3);

 

}

if (cont <= this.filas - 2)

{

this.vectorOferta.add(Integer.valueOf(num3));

this.oferta.add(Integer.valueOf(num3));

+= num3;

this.sumaOferta

this.auxOferta[cont] = Integer.valueOf(num3);

} cont++;

}

this.Tabla.setVisible(false);

this.TablaDatos3.setVisible(false);

this.temp = true;

}

private void Btn_EquilibrarActionPerformed(ActionEvent evt)

{

if (this.temp)

{

if (this.sumaDemanda > this.sumaOferta)

{

 

Equilibrio(true);

this.rec = true;

}

else

{

 

Equilibrio(false);

this.rec = false;

}

this.temp = false;

}

}

private void Btn_EsquinaNoroesteActionPerformed(ActionEvent evt)

{

try

{

String cadena = ""; resultado = 0; this.model.clear();

int calculOferta = 0;int calculoDemanda = 0; (this.sumaOferta == this.sumaDemanda)

int

if

{ for (int i = 1; i < this.filas - 1; i++) {

j < this.columnas - 1; j++)

{

for (int j = 1;

if (((Integer)this.vectorOferta.get(i - 1)).intValue() >=

((Integer)this.vectorDemanda.get(j - 1)).intValue())

{

if (((Integer)this.vectorDemanda.get(j - 1)).intValue() > 0)

{

cadena = cadena + "(" + this.matriz[i][j] + "*" + this.vectorDemanda.get(j - 1) + ")+";

resultado += Integer.parseInt(this.matriz[i][j] + "") *

((Integer)this.vectorDemanda.get(j - 1)).intValue();

this.tableModelDatos.setValueAt(this.vectorDemanda.get(j - 1), i, j); = ((Integer)this.vectorOferta.get(i - 1)).intValue() -

((Integer)this.vectorDemanda.get(j - 1)).intValue();

calculOferta

calculoDemanda = ((Integer)this.vectorDemanda.get(j - 1)).intValue()

- ((Integer)this.vectorDemanda.get(j - 1)).intValue();

this.vectorOferta.set(i - 1, Integer.valueOf(calculOferta)); this.vectorDemanda.set(j - 1, Integer.valueOf(calculoDemanda));

{

}

else

this.tableModelDatos.setValueAt("", i, j);

}

}

else if (((Integer)this.vectorOferta.get(i - 1)).intValue() > 0)

{

cadena = cadena + "(" + this.matriz[i][j] + "*" + this.vectorOferta.get(j - 1) + ")+";

resultado += Integer.parseInt(this.matriz[i][j] + "") *

((Integer)this.vectorOferta.get(j - 1)).intValue();

this.tableModelDatos.setValueAt(this.vectorOferta.get(i - 1), i, j); ((Integer)this.vectorOferta.get(i - 1)).intValue() -

((Integer)this.vectorOferta.get(i - 1)).intValue();

calculOferta =

calculoDemanda = ((Integer)this.vectorDemanda.get(j - 1)).intValue() -

((Integer)this.vectorOferta.get(i - 1)).intValue();

this.vectorOferta.set(i - 1, Integer.valueOf(calculOferta)); - 1, Integer.valueOf(calculoDemanda));

this.vectorDemanda.set(j

} else { this.tableModelDatos.setValueAt("", i, j); } if ((i + 1 == this.filas - 1)
}
else
{
this.tableModelDatos.setValueAt("", i, j);
}
if
((i
+
1
==
this.filas
-
1)
&&
(j
+
1
==
this.columnas
-
1))
{
this.tableModelDatos.setValueAt("Total " + this.sumaOferta, i + 1, j + 1);
}
}
}
this.Txta_Impresion.setText(cadena + " = " + resultado);
}
else
{
JOptionPane.showMessageDialog(this, "La oferta no cumple con la demanda");
catch (Exception e)
}
}

{

JOptionPane.showMessageDialog(this, e.getMessage());

}

}

int confila = 1;

ArrayList<Object> datosTem;

private

JButton BtnCostoMinimo;

Btn_Equilibrar;

private JButton

private JButton

Btn_EsquinaNoroeste;

Btn_Generar;

JTable TablaDatos2;

TablaDatos3;

Txta_Impresion;

private JButton

private JTable Tabla;

private JTable

private

private JTextArea private JLabel jLabel1;

private JLabel jLabel2;

jLabel3;

JLabel jLabel5;

private JPanel jPanel2;

private JLabel

private JLabel jLabel4;

private

private JPanel jPanel1;

private JScrollPane

jScrollPane1;

private JScrollPane

jScrollPane2;

private JScrollPane

jScrollPane3;

private JScrollPane

jScrollPane4;

private JTextField

txtNumColumna;

private JTextField

txtNumFilas;

private void BtnCostoMinimoActionPerformed(ActionEvent evt)

{

try

{

this.TablaDatos3.setVisible(true);

this.datosTem = new ArrayList();

int suma = 0;

int b =

sumaDatos();

while (suma

!= b)

{

int a = BuscarMenor();

if (((Integer)this.Demanda.get(this.auxj - 1)).intValue() >

((Integer)this.oferta.get(this.auxi - 1)).intValue())

{

this.TablaDatos3.setValueAt(this.oferta.get(this.auxi - 1), this.auxi, this.auxj);

this.datosTem.add(this.oferta.get(this.auxi - 1)); ((Integer)this.oferta.get(this.auxi - 1)).intValue(); ((Integer)this.Demanda.get(this.auxj - 1)).intValue() -

((Integer)this.oferta.get(this.auxi - 1)).intValue();

Integer.valueOf(0));

suma += int rec1 =

this.oferta.set(this.auxi - 1,

this.Demanda.set(this.auxj - 1, Integer.valueOf(rec1));

DatosX2(this.auxi, this.auxj);

{

}

else

this.TablaDatos3.setValueAt(this.Demanda.get(this.auxj - 1), this.auxi, this.auxj);

this.datosTem.add(this.Demanda.get(this.auxj - 1)); ((Integer)this.Demanda.get(this.auxj - 1)).intValue(); ((Integer)this.oferta.get(this.auxi - 1)).intValue() -

((Integer)this.Demanda.get(this.auxj - 1)).intValue();

Integer.valueOf(0));

suma += int rec1 =

this.Demanda.set(this.auxj - 1,

this.oferta.set(this.auxi - 1, Integer.valueOf(rec1));

DatosX(this.auxi, this.auxj);

}

}

this.Txta_Impresion.setText("Costo minimo = " + suma);

}

catch (Exception e)

{

JOptionPane.showMessageDialog(null, e.getCause());

}

}

public int BuscarMenor()

{

this.auxi = 0;

this.auxj =

0;

int aux = ValoxTemp();

for (int i = 1; i < this.filas - 1; i++) { this.columnas - 1; j++) {

if ((!(this.tableModelDatos3.getValueAt(i, j) + "").equals("x")) && Integer.parseInt(this.tableModelDatos3.getValueAt(i, j) + "")))

for (int j = 1; j <

(aux >

 

{

 

aux = Integer.parseInt(this.tableModelDatos3.getValueAt(i, j) + "");

this.auxi =

i;

}

this.auxj = j;

}

}

return

aux;

}

public void Equilibrio(boolean aux)

{

this.Tabla.setVisible(true);

if (aux)

{

this.auxDemanda[0] = "DEMANDA"; this.sumaDemanda - this.sumaOferta;

this.filas; i++) { if (i == this.filas - 1)

int sum = for (int i = 0; i <

for (int j = 0; j < this.columnas; j++) {

{

this.tableModelDatos.setValueAt(Integer.valueOf(0), i, j); this.tableModelDatos3.setValueAt(Integer.valueOf(0), i, j);

this.tableModelDatos.setValueAt("Suc " + i, i, j); + i, i, j);

if (j == 0)

{

this.tableModelDatos3.setValueAt("Suc "

}

if (j == this.columnas - 1)

{ this.tableModelDatos.setValueAt(Integer.valueOf(sum), i, j);

this.tableModelDatos3.setValueAt(Integer.valueOf(sum), i, j);

this.vectorOferta.add(Integer.valueOf(sum));

this.oferta.add(Integer.valueOf(sum));

}

}

}

}

this.mitableModel.addRow(this.auxDemanda);

this.mitableModel3.addRow(this.auxDemanda);

this.filas += 1;

this.sumaOferta += sum;

} else

{

int sum = this.sumaOferta -

this.sumaDemanda;

for (int j = 0; j < this.columnas; j++) { this.columnas - 1)

for (int i = 0; i < this.filas; i++) {

if (j ==

{

this.tableModelDatos.setValueAt(Integer.valueOf(0), i, j); this.tableModelDatos3.setValueAt(Integer.valueOf(0), i, j);

{ this.tableModelDatos.setValueAt("Pers " + j, i, j);

this.tableModelDatos3.setValueAt("Pers " + j, i, j);

if (i == 0)

}

if (i == this.filas - 1)

{ this.tableModelDatos.setValueAt(Integer.valueOf(sum), i, j);

this.tableModelDatos3.setValueAt(Integer.valueOf(sum), i, j);

this.vectorDemanda.add(Integer.valueOf(sum));

this.Demanda.add(Integer.valueOf(sum));

}

}

}

}

this.auxOferta[0] = "OFERTA";

this.mitableModel.addColumn("Z", this.auxOferta);

this.mitableModel3.addColumn("Z", this.auxOferta);

this.columnas += 1;

this.sumaDemanda += sum;

} sumaDatos();

}

public int ValoxTemp()

{

int aux = 0; rec = true;

boolean

for (int i = 1; i < this.filas - 1; i++) {

this.columnas - 1; j++) {

if ((rec) &&

for (int j = 1; j <

(!(this.tableModelDatos3.getValueAt(i, j) + "").equals("x")))

{

 

aux = Integer.parseInt(this.tableModelDatos3.getValueAt(i, j) + "");

rec = false;

}

}

}

return

aux;

}

public int sumaDatos()

{ int suma = 0;

for (int i = 0; i < this.Demanda.size(); i++) {

suma += ((Integer)this.Demanda.get(i)).intValue();

} return suma;

}

public void DatosX(int i, int j)

{

for (int h = 1; h < this.filas - 1; h++)

{

Object tem1 = Verificador(this.TablaDatos3.getValueAt(h, j)); (!tem1.equals("a")) {

if

}

}

this.TablaDatos3.setValueAt(this.TablaDatos3.getValueAt(h, j), i, j);

else { this.TablaDatos3.setValueAt("x", h, j);

}

}

public void DatosX2(int i, int j)

{

for (int h = 1; h < this.columnas - 1; h++)

{

Object tem2 = Verificador(this.TablaDatos3.getValueAt(i, h)); (!tem2.equals("a")) {

if

}

this.TablaDatos3.setValueAt(this.TablaDatos3.getValueAt(i, h), i, h);

else { this.TablaDatos3.setValueAt("x", i, h);

}

}

}

public Object Verificador(Object dato)

{

Object rec = "a";

for (int i = 0; i < this.datosTem.size(); i++) { (this.datosTem.get(i).equals(dato))

{ rec = this.datosTem.get(i); = this.datosTem.size();

i

}

rec;

}

return

if

}

public static void main(String[] args)

 

{

try

{

for (UIManager.LookAndFeelInfo info : )

{

if ("Nimbus".equals(info.getName()))

 

{

UIManager.setLookAndFeel(info.getClassName());

break;

}

 

}

}

catch (ClassNotFoundException ex)

 

{

Logger.getLogger(Ejecutar.class.getName()).log(Level.SEVERE, null, ex);

}

catch (InstantiationException ex)

 

{

Logger.getLogger(Ejecutar.class.getName()).log(Level.SEVERE, null, ex);

}

catch (IllegalAccessException ex)

 

{

Logger.getLogger(Ejecutar.class.getName()).log(Level.SEVERE, null, ex);

}

catch (UnsupportedLookAndFeelException ex)

 

{

Logger.getLogger(Ejecutar.class.getName()).log(Level.SEVERE, null, ex);

}

EventQueue.invokeLater(new Runnable()

 

{

public void run()

 

{

 

new Ejecutar().setVisible(true);

 
 

}

});

 

}

}

Ejercicio 4

} Ejercicio 4 import java.awt.Color; import java.awt.Container; import java.awt.Dimension; import

import java.awt.Color; import java.awt.Container; import java.awt.Dimension; import java.awt.EventQueue; import java.awt.Font; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.util.Iterator; import java.util.Stack; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.BorderFactory; import javax.swing.GroupLayout; import javax.swing.GroupLayout.Alignment; import javax.swing.GroupLayout.ParallelGroup; import javax.swing.GroupLayout.SequentialGroup; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import

javax.swing.JOptionPane; import javax.swing.JPanel;

import javax.swing.LayoutStyle.ComponentPlacement; import javax.swing.UIManager; import javax.swing.UIManager.LookAndFeelInfo; import javax.swing.UnsupportedLookAndFeelException;

public class PlayGame private VFondo fondo;

= false;

extends JFrame {

private boolean caraUp

private

private ImageIcon im1;

ImageIcon im2;

JButton[2];

private int puntaje = 0;

private JButton[] pbtn = new

private boolean primerc = false;

public PlayGame()

{

initComponents();

this.fondo = new VFondo(getWidth(), getHeight());

add(this.fondo, "Center");

}

setCards();

PilaJuego objLogica = new PilaJuego();

private JButton btnC1;

btnC10;

JButton btnC12;

private JButton btnC14;

btnC15;

JButton btnC2;

private JButton btnC4; private JButton btnC6;

private JButton btnC8;

private JButton btnReiniciar;

jLabel1;

private JButton

private JButton btnC11;

private JButton btnC16;

private

private JButton btnC13;

private JButton

private

private JButton btnC3;

private JButton btnC5; private JButton btnC7;

private JButton btnC9;

private JLabel

private JPanel jPanel1;

private void setCards()

{

Stack pila = this.objLogica.getCardNumbers();

Iterator auxInte = pila.iterator();

int[16];

int[] numbers = new

int aux = 0;

while (auxInte.hasNext())

{

Object tem = auxInte.next();

int num =

Integer.parseInt(tem.toString()); numbers[aux] = num; aux++; }

this.btnC1.setDisabledIcon(new ImageIcon(getClass().getResource("/imagenes/c" + numbers[0]

+ ".png")));

this.btnC2.setDisabledIcon(new ImageIcon(getClass().getResource("/imagenes/c" + numbers[1]

+ ".png")));

this.btnC3.setDisabledIcon(new ImageIcon(getClass().getResource("/imagenes/c" + numbers[2]

+ ".png")));

this.btnC4.setDisabledIcon(new ImageIcon(getClass().getResource("/imagenes/c" + numbers[3]

+ ".png")));

this.btnC5.setDisabledIcon(new ImageIcon(getClass().getResource("/imagenes/c" + numbers[4]

+ ".png")));

this.btnC6.setDisabledIcon(new ImageIcon(getClass().getResource("/imagenes/c" + numbers[5]

+ ".png")));

this.btnC7.setDisabledIcon(new ImageIcon(getClass().getResource("/imagenes/c" + numbers[6]

+ ".png")));

this.btnC8.setDisabledIcon(new ImageIcon(getClass().getResource("/imagenes/c" + numbers[7]

+ ".png")));

this.btnC9.setDisabledIcon(new ImageIcon(getClass().getResource("/imagenes/c" + numbers[8]

+ ".png")));

this.btnC10.setDisabledIcon(new ImageIcon(getClass().getResource("/imagenes/c" + numbers[9] + ".png")));

this.btnC11.setDisabledIcon(new ImageIcon(getClass().getResource("/imagenes/c" + numbers[10] + ".png")));

this.btnC12.setDisabledIcon(new ImageIcon(getClass().getResource("/imagenes/c" + numbers[11] + ".png")));

this.btnC13.setDisabledIcon(new ImageIcon(getClass().getResource("/imagenes/c" + numbers[12] + ".png")));

this.btnC14.setDisabledIcon(new ImageIcon(getClass().getResource("/imagenes/c" + numbers[13] + ".png")));

this.btnC15.setDisabledIcon(new ImageIcon(getClass().getResource("/imagenes/c" + numbers[14] + ".png")));

this.btnC16.setDisabledIcon(new ImageIcon(getClass().getResource("/imagenes/c" + numbers[15] + ".png")));

}

private void btnEnabled(JButton btn)

{

if (!this.caraUp)

{

btn.setEnabled(false);

this.im1 = ((ImageIcon)btn.getDisabledIcon());

this.pbtn[0] = btn; false;

}

else

{

this.caraUp = true;

this.primerc =

btn.setEnabled(false);

this.im2 = ((ImageIcon)btn.getDisabledIcon());

this.pbtn[1] = btn;

20;

pregwin();

}

this.primerc = true;

this.puntaje +=

}

private void compare()

{

if ((this.caraUp) && (this.primerc))

{

if (this.im1.getDescription().compareTo(this.im2.getDescription()) != 0)

{

this.pbtn[0].setEnabled(true);

this.pbtn[1].setEnabled(true);

(this.puntaje > 10) {

if

this.puntaje -= 10;

}

}

this.caraUp = false;

}

}

private void reiniciar()

{ this.btnC1.setEnabled(true);

this.btnC2.setEnabled(true);

this.btnC3.setEnabled(true);

this.btnC4.setEnabled(true);

this.btnC5.setEnabled(true);

this.btnC6.setEnabled(true);

this.btnC7.setEnabled(true);

this.btnC8.setEnabled(true);

this.btnC9.setEnabled(true);

this.btnC10.setEnabled(true);

this.btnC11.setEnabled(true);

this.btnC12.setEnabled(true);

this.btnC13.setEnabled(true);

this.btnC14.setEnabled(true);

this.btnC15.setEnabled(true);

this.btnC16.setEnabled(true);

this.primerc = false;

false;

this.puntaje = 0;

this.caraUp =

}

private void pregwin()

{

if ((!this.btnC1.isEnabled()) && (!this.btnC2.isEnabled()) &&

(!this.btnC3.isEnabled()) && (!this.btnC4.isEnabled()) && (!this.btnC5.isEnabled())

&& (!this.btnC6.isEnabled()) &&

(!this.btnC7.isEnabled()) && (!this.btnC8.isEnabled()) &&

(!this.btnC9.isEnabled()) && (!this.btnC10.isEnabled()) && (!this.btnC11.isEnabled()) &&

(!this.btnC12.isEnabled()) && (!this.btnC13.isEnabled()) &&

(!this.btnC14.isEnabled()) && (!this.btnC15.isEnabled()) &&

(!this.btnC16.isEnabled())) {

JOptionPane.showMessageDialog(this, "Felicidades, usted ha ganado. Su puntaje es: " + this.puntaje, "Win!!", 1);

}

}

private void initComponents()

{ this.jLabel1 = new JLabel(); this.jPanel1 = new JPanel(); this.btnC1 = new JButton(); this.btnC2 = new JButton(); this.btnC3 = new JButton(); this.btnC4 = new JButton(); this.btnC8 = new JButton();

this.btnC7 = new JButton(); this.btnC6 = new JButton(); this.btnC5 = new JButton(); this.btnC12 = new JButton(); this.btnC11 = new JButton(); this.btnC10 = new JButton(); this.btnC9 = new JButton(); this.btnC16 = new JButton(); this.btnC15 = new JButton(); this.btnC14 = new JButton(); this.btnC13 = new JButton(); this.btnReiniciar = new JButton();

setDefaultCloseOperation(3);

Caras");

setTitle("Juego Dos

this.jLabel1.setFont(new Font("Tahoma", 1, 18));

this.jLabel1.setForeground(new

Color(102, 102, 102));

this.jLabel1.setText("BIENVENIDO");

this.jPanel1.setBackground(new Color(204, 0, 0));

this.jPanel1.setBorder(BorderFactory.createLineBorder(new Color(0, 0, 0)));

this.btnC1.setIcon(new ImageIcon(getClass().getResource("/imagenes/c0.png")));

this.btnC1.setBorder(null);

this.btnC1.setContentAreaFilled(false);

this.btnC1.setRolloverIcon(new

ImageIcon(getClass().getResource("/imagenes/cr.png")));

MouseAdapter()

this.btnC1.setBorderPainted(false);

this.btnC1.setFocusable(false);

this.btnC1.addMouseListener(new

{

public void mouseExited(MouseEvent evt)