Está en la página 1de 35

Tecnológico de Estudios Superiores de Ecatepec

División de la Ingeniería en Sistemas Computacionales

Materia: Teoría de la computación


Profesora: Rosa María Hernández Rojas

Integrantes del equipo:


Manzano Palacios Iván
Gonzales Sánchez Ahydee Esmeralda

Proyecto 1er Parcial


Autómata de Maquina de Refrescos
INTRODUCCIÓN

Autómata, del latín automăta y este del griego automatos (αὐτόματος), espontáneo o con
movimiento propio. Según la RAE, máquina que imita la figura y los movimientos de un ser
animado. Un equivalente tecnológico en la actualidad serían los robots autónomos. Si el robot es
antropomorfo se conoce como androide.

El mundo de los autómatas es tan amplio como su definición. En términos bíblicos


podríamos considerar al hombre como el primer autómata, creado del barro por Dios, aunque con
la diferencia de poseer libre albedrío que le permite decidir por sí mismo. Esa distinción ha hecho
que el ser humano haya querido imitar el acto de la creación desde el mismo inicio de su historia,
construyendo mecanismos artificiales para todo tipo de fines desde científicos, de investigación,
para agilizar sus tareas o por mero entretenimiento.

Los autómatas son mecanismos formales que realizan derivaciones en gramáticas


formales. La manera en que las realizan es mediante la nocion del reconocimiento.

Una palabra es generada si y solo si la palabra hace transitar al autómata correspondiente


a sus condiciones terminales.

Por esto es que los autómatas son analizadores léxicos de las gramáticas que les
corresponden.
Justificación

La creación de este programa es para demostrar el funcionamiento de un autómata de


una maquina de refrescos, mostrando así los conocimientos adquiridos en clase, con la finalidad
de mostrar

Objetivo General

El objetivo de este proyecto es la realización un una maquina de refrescos virtual que nos
muestre como debe de funcionar un autómata de una máquina expendedora de refrescos.

Objetivo particular

Aprender a programar un autómata y sus diferentes estados para desarrollar una mejor
lógica de programación.
Desarrollo del programa

Caminos que el autómata q0


puede seguir
1 2
5

q1 1 q2
5
2 10 1 5 2
10 10
q3 1 q4

2 5,10 1 5, 10 2

q5 1 q6
5,10 1
2

2, 5, 10
q7

1, 2, 5,10
q8
COMBINACIONES TOTALES QUE EL AUTÓMATA PUEDE CONSEGUIR

0 9
21. a,b,b,a,a,a
1. a,a,a,a,a,a,a,a 22. a,b,b,a,a,b
2. a,a,a,a,a,a,a,b 23. a,b,b,a,a,c
3. a,a,a,a,a,a,a,c 24. a,b,b,a,a,d
4. a,a,a,a,a,a,a,d
10
1 25. a,b,a,b,a,a
5. a,a,a,a,a,a,b 26. a,b,a,b,a,b
6. a,a,a,a,a,a,c 27. a,b,a,b,a,c
7. a,a,a,a,a,a,d 28. a,b,a,b,a,d

2 11
8. a,a,a,a,a,c 29. a,b,a,a,b,a
9. a,a,a,a,a,d 30. a,b,a,a,b,b
31. a,b,a,a,b,c
3 32. a,b,a,a,b,d
10. a,a,a,a,c
11. a,a,a,a,d 12
33. a,b,a,a,a,b
4 34. a,b,a,a,a,c
12. a,a,a,c 35. a,b,a,a,a,d
13. a,a,a,d
13
5 36. a,a,b,b,a,a
14. a,a,d 37. a,a,b,b,a,b
38. a,a,b,b,a,c
6 39. a,a,b,b,a,d
15. a,d
14
7 40. a,a,b,a,b,a
16. d 41. a,a,b,a,b,b
42. a,a,b,a,b,c
8 43. a,a,b,a,b,d
17. a,b,a,a,a,a,a
18. a,b,a,a,a,a,b 15
19. a,b,a,a,a,a,c 44. a,a,b,a,a,b
20. a,b,a,a,a,a,d 45. a,a,b,a,a,c
46. a,a,b,a,a,d
16 22
47. a,a,a,b,b,a 70. a,c,a,a
48. a,a,a,b,b,b 71. a,c,a,b
49. a,a,a,b,b,c 72. a,c,a,c
50. a,a,a,b,b,d 73. a,c,a,d

17 23
51. a,a,a,b,a,b 74. a,a,c,a
52. a,a,a,b,a,c 75. a,a,c,b
53. a,a,a,b,a,d 76. a,a,c,c
77. a,a,c,d

42 24
54. a,a,a,a,b,b 78. a,a,a,c
55. a,a,a,a,b,c 79. a,a,a,d
56. a,a,a,a,b,d
25
18 80. a,c,b
57. a,b,b,b,a 81. a,c,c
58. a,b,b,b,b 82. a,c,d
59. a,b,b,b,c
60. a,b,b,b,d 26
83. b,a,a,a,a,a,a
19 84. b,a,a,a,a,a,b
61. a,b,a,b,b 85. b,a,a,a,a,a,c
62. a,b,a,b,c 86. b,a,a,a,a,a,d
63. a,b,a,b,d
27
20 87. b,b,a,a,a,a
64. a,b,b,a,b 88. b,b,a,a,a,b
65. a,b,b,a,c 89. b,b,a,a,a,c
66. a,b,b,a,d 90. b,b,a,a,a,d

21 28
67. a,a,b,b,b 91. b,a,b,a,a,a
68. a,a,b,b,c 92. b,a,b,a,a,b
69. a,a,b,b,d 93. b,a,b,a,a,c
94. b,a,b,a,a,d
29 34
95. b,a,a,b,a,a 114. b,a,a,b,b
96. b,a,a,b,a,b 115. b,a,a,b,c
97. b,a,a,b,a,c 116. b,a,a,b,d
98. b,a,a,b,a,d
35
30 117. b,b,b,b
99. b,a,a,a,b,a
100. b,a,a,a,b,b 36
101. b,a,a,a,b,c 118. b,c,a
102. b,a,a,a,b,d 119. b,c,b
120. b,c,c
31 121. b,c,d
103. b,a,a,a,a,b 37
104. b,a,a,a,a,c 122. b,d
105. b,a,a,a,a,d
38
32 123. c,a,a,a
106. b,b,b,a,a 124. c,a,a,b
107. b,b,b,a,b 125. c,a,a,c
108. b,b,b,a,c 126. c,a,a,d
109. b,b,b,a,a
39
33 127. c,a,b
110. b,a,b,b,a 128. c,a,c
111. b,a,b,b,b 129. c,a,d
112. b,a,b,b,c
113. b,a,b,b,d 40
130. c,b,a
131. c,b,b
132. c,b,c

41
133. c,c
134. c,d
// Codigo de la Clase que crea el frame de la maquina de refrescos y genera el frame del automata

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

/*
* Interfase.java
*
* Created on 2/10/2010, 12:29:06 PM
*/

package automata;

import java.awt.Component;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

/**
*
* @author Ivan
*/
public class Interfase extends javax.swing.JFrame {

int cambio,dinero_maquina, dinero_ingresado, latas_maquina;


String cadena;
//JPanel dibuja = new JPanel();
JLabel dibuja = new JLabel();
ImageIcon[] latas = {

new
ImageIcon(getClass().getResource("/Iconos/lata_coca.jpg")),
//new ImageIcon("img\\spriteZero -lata.gif"),
new
ImageIcon(getClass().getResource("/Iconos/lata_fanta.jpg")),
new
ImageIcon(getClass().getResource("/Iconos/lata_sprite.jpg")),
new
ImageIcon(getClass().getResource("/Iconos/lata_sangria.jpg")),
new
ImageIcon(getClass().getResource("/Iconos/lata_manzana.jpg")),
new
ImageIcon(getClass().getResource("/Iconos/lata_coca_light.jpg"))
};
ImageIcon[] automata = {

new
ImageIcon(getClass().getResource("/Iconos/dibuja/0 aaaaaaaa.jpg")),//0
//new ImageIcon("img\\spriteZero -lata.gif"),
new
ImageIcon(getClass().getResource("/Iconos/dibuja/1 aaaaaab.jpg")),//1
new
ImageIcon(getClass().getResource("/Iconos/dibuja/2 aaaaac.jpg")),//2
new
ImageIcon(getClass().getResource("/Iconos/dibuja/3 aaaac.jpg")),//3
new
ImageIcon(getClass().getResource("/Iconos/dibuja/4 aaac.jpg")),//4
new
ImageIcon(getClass().getResource("/Iconos/dibuja/5 aad.jpg")),//5
new
ImageIcon(getClass().getResource("/Iconos/dibuja/6 ad.jpg")),//6
new
ImageIcon(getClass().getResource("/Iconos/dibuja/7 d.jpg")),//7
new
ImageIcon(getClass().getResource("/Iconos/dibuja/8 abaaaaa.jpg")),//8
new
ImageIcon(getClass().getResource("/Iconos/dibuja/9 abbaaa.jpg")),//9
new
ImageIcon(getClass().getResource("/Iconos/dibuja/10 ababaa.jpg")),//10
new
ImageIcon(getClass().getResource("/Iconos/dibuja/11 abaaba.jpg")),//11
new
ImageIcon(getClass().getResource("/Iconos/dibuja/12 abaaab.jpg")),//12
new
ImageIcon(getClass().getResource("/Iconos/dibuja/13 aabbaa.jpg")),//13
new
ImageIcon(getClass().getResource("/Iconos/dibuja/14 aababa.jpg")),//14
new
ImageIcon(getClass().getResource("/Iconos/dibuja/15 aabaab.jpg")),//15
new
ImageIcon(getClass().getResource("/Iconos/dibuja/16 aaabba.jpg")),//16
new
ImageIcon(getClass().getResource("/Iconos/dibuja/17 aaabab.jpg")),//17
new
ImageIcon(getClass().getResource("/Iconos/dibuja/18 abbba.jpg")),//18
new
ImageIcon(getClass().getResource("/Iconos/dibuja/19 ababb.jpg")),//19
new
ImageIcon(getClass().getResource("/Iconos/dibuja/20 abbab.jpg")),//20
new
ImageIcon(getClass().getResource("/Iconos/dibuja/21 aabbb.jpg")),//21
new
ImageIcon(getClass().getResource("/Iconos/dibuja/22 acaa.jpg")),//22
new
ImageIcon(getClass().getResource("/Iconos/dibuja/23 aaca.jpg")),//23
new
ImageIcon(getClass().getResource("/Iconos/dibuja/24 aaac.jpg")),//24
new
ImageIcon(getClass().getResource("/Iconos/dibuja/25 acb.jpg")),//25
new
ImageIcon(getClass().getResource("/Iconos/dibuja/26 baaaaaa.jpg")),//26
new
ImageIcon(getClass().getResource("/Iconos/dibuja/27 bbaaaa.jpg")),//27
new
ImageIcon(getClass().getResource("/Iconos/dibuja/28 babaaa.jpg")),//28
new
ImageIcon(getClass().getResource("/Iconos/dibuja/29 baabaa.jpg")),//29
new
ImageIcon(getClass().getResource("/Iconos/dibuja/30 baaaba.jpg")),//30
new
ImageIcon(getClass().getResource("/Iconos/dibuja/31 baaaab.jpg")),//31
new
ImageIcon(getClass().getResource("/Iconos/dibuja/32 bbbaa.jpg")),//32
new
ImageIcon(getClass().getResource("/Iconos/dibuja/33 babba.jpg")),//33
new
ImageIcon(getClass().getResource("/Iconos/dibuja/34 baabb.jpg")),//34
new
ImageIcon(getClass().getResource("/Iconos/dibuja/35 bbbb.jpg")),//35
new
ImageIcon(getClass().getResource("/Iconos/dibuja/36 bca.jpg")),//36
new
ImageIcon(getClass().getResource("/Iconos/dibuja/37 bd.jpg")),//37
new
ImageIcon(getClass().getResource("/Iconos/dibuja/38 caaa.jpg")),//38
new
ImageIcon(getClass().getResource("/Iconos/dibuja/39 cab.jpg")),//39
new
ImageIcon(getClass().getResource("/Iconos/dibuja/40 cba.jpg")),//40
new
ImageIcon(getClass().getResource("/Iconos/dibuja/41 cc.jpg")),//41
new
ImageIcon(getClass().getResource("/Iconos/dibuja/42 aaaabb.jpg")),//42
};

/** Creates new form Interfase */


public Interfase() {
initComponents();

dinero_maquina=300;
latas_maquina=100;
cadena="";

btn_toma_y_recoge.setEnabled(false);
btn_coca.setVisible(false);
btn_fanta.setVisible(false);
btn_sprite.setVisible(false);
btn_sangria.setVisible(false);
btn_manzana.setVisible(false);
btn_coca_light.setVisible(false);
btn_seguir.setVisible(false);
btn_dibuja_automata.setVisible(false);
pnl_recoge.setVisible(false);

lbl_cambio.setText("$");
lbl_ingresado.setText("$");
lbl_dinero_maquina.setText("$"+dinero_maquina);
lbl_latas.setText(""+latas_maquina);
}

/** 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">//GEN-
BEGIN:initComponents
private void initComponents() {

btn_1_peso = new javax.swing.JButton();


btn_2_pesos = new javax.swing.JButton();
btn_5_pesos = new javax.swing.JButton();
btn_10_pesos = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
lbl_dinero_maquina = new javax.swing.JLabel();
lbl_latas = new javax.swing.JLabel();
lbl_ingresado = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
btn_toma_y_recoge = new javax.swing.JButton();
btn_coca = new javax.swing.JButton();
btn_fanta = new javax.swing.JButton();
btn_sprite = new javax.swing.JButton();
btn_sangria = new javax.swing.JButton();
jLabel4 = new javax.swing.JLabel();
lbl_cambio = new javax.swing.JLabel();
btn_seguir = new javax.swing.JButton();
btn_manzana = new javax.swing.JButton();
btn_coca_light = new javax.swing.JButton();
pnl_recoge = new javax.swing.JPanel();
lbl_recoge = new javax.swing.JLabel();
btn_dibuja_automata = new javax.swing.JButton();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setBounds(new java.awt.Rectangle(0, 0, 0, 0));

btn_1_peso.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/Iconos/un_patipeso.png")))
; // NOI18N
btn_1_peso.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt) {
btn_1_pesoActionPerformed(evt);
}
});

btn_2_pesos.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/Iconos/dos_patipesos.png")
)); // NOI18N
btn_2_pesos.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt) {
btn_2_pesosActionPerformed(evt);
}
});

btn_5_pesos.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/Iconos/cinco_patipesos.png
"))); // NOI18N
btn_5_pesos.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt) {
btn_5_pesosActionPerformed(evt);
}
});

btn_10_pesos.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/Iconos/diez_patipesos.png"
))); // NOI18N
btn_10_pesos.addActionListener(new
java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btn_10_pesosActionPerformed(evt);
}
});

jLabel1.setText("Ingresa Dinero");

lbl_dinero_maquina.setText(".");

lbl_latas.setText(".");

lbl_ingresado.setText(".");

jLabel2.setText("Dinero inside");

jLabel3.setText("Latas");

jLabel5.setText("Dinero insertado");

btn_toma_y_recoge.setText("Tomar cambio y elegir Refresco");


btn_toma_y_recoge.addActionListener(new
java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btn_toma_y_recogeActionPerformed(evt);
}
});

btn_coca.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/Iconos/logo_coca.jpg")));
// NOI18N
btn_coca.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btn_cocaActionPerformed(evt);
}
});
btn_fanta.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/Iconos/logo_fanta.jpg")));
// NOI18N
btn_fanta.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btn_fantaActionPerformed(evt);
}
});

btn_sprite.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/Iconos/logo_sprite.jpg")))
; // NOI18N
btn_sprite.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt) {
btn_spriteActionPerformed(evt);
}
});

btn_sangria.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/Iconos/logo_sangria.jpg"))
); // NOI18N
btn_sangria.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt) {
btn_sangriaActionPerformed(evt);
}
});

jLabel4.setText("Su cambio:");

lbl_cambio.setText(".");

btn_seguir.setText("Seguir comprando");
btn_seguir.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt) {
btn_seguirActionPerformed(evt);
}
});

btn_manzana.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/Iconos/logo_manzana.jpg"))
); // NOI18N
btn_manzana.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt) {
btn_manzanaActionPerformed(evt);
}
});

btn_coca_light.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/Iconos/logo_coca_ligth.jpg
"))); // NOI18N
btn_coca_light.addActionListener(new
java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btn_coca_lightActionPerformed(evt);
}
});

pnl_recoge.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.sw
ing.border.BevelBorder.LOWERED));

javax.swing.GroupLayout pnl_recogeLayout = new


javax.swing.GroupLayout(pnl_recoge);
pnl_recoge.setLayout(pnl_recogeLayout);
pnl_recogeLayout.setHorizontalGroup(

pnl_recogeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LE
ADING)
.addGroup(pnl_recogeLayout.createSequentialGroup()
.addContainerGap()
.addComponent(lbl_recoge,
javax.swing.GroupLayout.DEFAULT_SIZE, 152, Short.MAX_VALUE)
.addContainerGap())
);
pnl_recogeLayout.setVerticalGroup(

pnl_recogeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LE
ADING)
.addComponent(lbl_recoge,
javax.swing.GroupLayout.DEFAULT_SIZE, 257, Short.MAX_VALUE)
);

btn_dibuja_automata.setText("Dibujar automata");
btn_dibuja_automata.addActionListener(new
java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btn_dibuja_automataActionPerformed(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()
.addContainerGap()

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LE
ADING)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TR
AILING, false)
.addComponent(btn_coca_light,
javax.swing.GroupLayout.Alignment.LEADING, 0, 0, Short.MAX_VALUE)
.addComponent(btn_manzana,
javax.swing.GroupLayout.Alignment.LEADING, 0, 0, Short.MAX_VALUE)
.addComponent(btn_sangria,
javax.swing.GroupLayout.Alignment.LEADING, 0, 0, Short.MAX_VALUE)
.addComponent(btn_sprite,
javax.swing.GroupLayout.Alignment.LEADING, 0, 0, Short.MAX_VALUE)
.addComponent(btn_fanta,
javax.swing.GroupLayout.Alignment.LEADING, 0, 0, Short.MAX_VALUE)
.addComponent(btn_coca,
javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.PREFERRED_SIZE, 116, Short.MAX_VALUE))
.addComponent(pnl_recoge,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup()
.addComponent(btn_seguir)
.addGap(18, 18, 18)
.addComponent(btn_dibuja_automata)))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LE
ADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LE
ADING)

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

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TR
AILING, false)
.addComponent(btn_5_pesos,
javax.swing.GroupLayout.Alignment.LEADING, 0, 0, Short.MAX_VALUE)
.addComponent(btn_1_peso,
javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.PREFERRED_SIZE, 153, Short.MAX_VALUE)
.addComponent(jLabel1))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LE
ADING)
.addComponent(btn_2_pesos,
javax.swing.GroupLayout.PREFERRED_SIZE, 145,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(btn_10_pesos,
javax.swing.GroupLayout.PREFERRED_SIZE, 145,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(142, 142, 142))

.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TR
AILING)

.addGroup(layout.createSequentialGroup()
.addGap(18, 18, 18)
.addComponent(jLabel2))
.addComponent(jLabel3)
.addComponent(jLabel5))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LE
ADING, false)
.addComponent(lbl_dinero_maquina,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(lbl_latas,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(lbl_ingresado,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addGap(105, 105, 105)
.addComponent(jLabel4)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(lbl_cambio,
javax.swing.GroupLayout.PREFERRED_SIZE, 85,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(46, 46, 46)))
.addContainerGap())
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addComponent(btn_toma_y_recoge)
.addGap(71, 71, 71))))
);
layout.setVerticalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel1)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LE
ADING)
.addGroup(layout.createSequentialGroup()

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btn_coca,
javax.swing.GroupLayout.PREFERRED_SIZE, 41,
javax.swing.GroupLayout.PREFERRED_SIZE)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btn_fanta,
javax.swing.GroupLayout.PREFERRED_SIZE, 42,
javax.swing.GroupLayout.PREFERRED_SIZE)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(btn_sprite,
javax.swing.GroupLayout.PREFERRED_SIZE, 43,
javax.swing.GroupLayout.PREFERRED_SIZE)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(btn_sangria,
javax.swing.GroupLayout.PREFERRED_SIZE, 43,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(36, 36, 36)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LE
ADING, false)
.addComponent(btn_2_pesos,
javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(btn_1_peso,
javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LE
ADING, false)
.addGroup(layout.createSequentialGroup()
.addComponent(btn_manzana)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btn_coca_light,
javax.swing.GroupLayout.PREFERRED_SIZE, 52,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(pnl_recoge,
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.BA
SELINE)
.addComponent(btn_seguir)
.addComponent(btn_dibuja_automata)))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LE
ADING)
.addComponent(btn_10_pesos)
.addComponent(btn_5_pesos))
.addGap(55, 55, 55)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BA
SELINE)
.addComponent(lbl_dinero_maquina)
.addComponent(jLabel2))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BA
SELINE)
.addComponent(lbl_latas)
.addComponent(jLabel3))
.addGap(18, 18, 18)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BA
SELINE)
.addComponent(lbl_ingresado)
.addComponent(jLabel5))
.addGap(18, 18, 18)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BA
SELINE)
.addComponent(lbl_cambio)
.addComponent(jLabel4))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(btn_toma_y_recoge)
.addGap(334, 334, 334))))
);

pack();
}// </editor-fold>//GEN-END:initComponents

private void
btn_toma_y_recogeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-
FIRST:event_btn_toma_y_recogeActionPerformed

cambio=dinero_ingresado-8;
lbl_cambio.setText("$" +cambio);
latas_maquina=latas_maquina-1;

dinero_maquina=dinero_maquina-cambio;
lbl_dinero_maquina.setText("S"+dinero_maquina);

btn_coca.setVisible(true);
btn_fanta.setVisible(true);
btn_sprite.setVisible(true);
btn_sangria.setVisible(true);
btn_coca_light.setVisible(true);
btn_manzana.setVisible(true);
btn_toma_y_recoge.setEnabled(false);

pnl_recoge.setVisible(true);
lbl_latas.setText(""+ latas_maquina);

// TODO add your handling code here:


}//GEN-LAST:event_btn_toma_y_recogeActionPerformed

private void btn_1_pesoActionPerformed(java.awt.event.ActionEvent


evt) {//GEN-FIRST:event_btn_1_pesoActionPerformed

dinero_ingresado+=+1;

dinero_maquina+=+1;

cadena+="a";

if(dinero_ingresado>=8)
{
btn_1_peso.setEnabled(false);
btn_2_pesos.setEnabled(false);
btn_5_pesos.setEnabled(false);
btn_10_pesos.setEnabled(false);
btn_toma_y_recoge.setEnabled(true);
}

lbl_ingresado.setText("$"+ dinero_ingresado);
lbl_dinero_maquina.setText("$"+dinero_maquina);

// TODO add your handling code here:


}//GEN-LAST:event_btn_1_pesoActionPerformed

private void btn_2_pesosActionPerformed(java.awt.event.ActionEvent


evt) {//GEN-FIRST:event_btn_2_pesosActionPerformed

dinero_ingresado+=+2;

dinero_maquina+=+2;
cadena+="b";

if(dinero_ingresado>=8)
{
btn_1_peso.setEnabled(false);
btn_2_pesos.setEnabled(false);
btn_5_pesos.setEnabled(false);
btn_10_pesos.setEnabled(false);
btn_toma_y_recoge.setEnabled(true);
}
lbl_ingresado.setText("$"+ dinero_ingresado);
lbl_dinero_maquina.setText("$"+dinero_maquina);

// TODO add your handling code here:


}//GEN-LAST:event_btn_2_pesosActionPerformed

private void btn_5_pesosActionPerformed(java.awt.event.ActionEvent


evt) {//GEN-FIRST:event_btn_5_pesosActionPerformed

dinero_ingresado+=+5;

dinero_maquina+=+5;

cadena+="c";
//lbl_cadena.setText(cadena);

if(dinero_ingresado>=8)
{
btn_1_peso.setEnabled(false);
btn_2_pesos.setEnabled(false);
btn_5_pesos.setEnabled(false);
btn_10_pesos.setEnabled(false);
btn_toma_y_recoge.setEnabled(true);
}

lbl_ingresado.setText("$"+ dinero_ingresado);
lbl_dinero_maquina.setText("$"+dinero_maquina);
// TODO add your handling code here:

}//GEN-LAST:event_btn_5_pesosActionPerformed

private void btn_10_pesosActionPerformed(java.awt.event.ActionEvent


evt) {//GEN-FIRST:event_btn_10_pesosActionPerformed

dinero_ingresado+=+10;

dinero_maquina+=+10;
cadena+="d";

if(dinero_ingresado>=8)
{
btn_1_peso.setEnabled(false);
btn_2_pesos.setEnabled(false);
btn_5_pesos.setEnabled(false);
btn_10_pesos.setEnabled(false);
btn_toma_y_recoge.setEnabled(true);
}

lbl_ingresado.setText("$"+ dinero_ingresado);
lbl_dinero_maquina.setText("$"+dinero_maquina);

// TODO add your handling code here:


}//GEN-LAST:event_btn_10_pesosActionPerformed

private void btn_seguirActionPerformed(java.awt.event.ActionEvent


evt) {//GEN-FIRST:event_btn_seguirActionPerformed
btn_1_peso.setEnabled(true);
btn_2_pesos.setEnabled(true);
btn_5_pesos.setEnabled(true);
btn_10_pesos.setEnabled(true);
btn_toma_y_recoge.setEnabled(false);
btn_coca.setVisible(false);
btn_fanta.setVisible(false);
btn_sprite.setVisible(false);
btn_sangria.setVisible(false);
btn_coca_light.setVisible(false);
btn_manzana.setVisible(false);
btn_seguir.setVisible(false);
btn_dibuja_automata.setVisible(false);
pnl_recoge.setVisible(false);

dinero_ingresado=0;
lbl_ingresado.setText("$");
lbl_cambio.setText("$");
lbl_recoge.setIcon(null);
cadena="";

// TODO add your handling code here:


}//GEN-LAST:event_btn_seguirActionPerformed

private void btn_cocaActionPerformed(java.awt.event.ActionEvent evt)


{//GEN-FIRST:event_btn_cocaActionPerformed

lbl_recoge.setIcon(latas[0]);
btn_seguir.setVisible(true);

btn_coca.setVisible(false);
btn_coca_light.setVisible(false);
btn_fanta.setVisible(false);
btn_manzana.setVisible(false);
btn_sangria.setVisible(false);
btn_sprite.setVisible(false);
btn_dibuja_automata.setVisible(true);
// TODO add your handling code here:
}//GEN-LAST:event_btn_cocaActionPerformed

private void btn_fantaActionPerformed(java.awt.event.ActionEvent evt)


{//GEN-FIRST:event_btn_fantaActionPerformed

lbl_recoge.setIcon(latas[1]);
btn_seguir.setVisible(true);

btn_coca.setVisible(false);
btn_coca_light.setVisible(false);
btn_fanta.setVisible(false);
btn_manzana.setVisible(false);
btn_sangria.setVisible(false);
btn_sprite.setVisible(false);
btn_dibuja_automata.setVisible(true);
// TODO add your handling code here:
}//GEN-LAST:event_btn_fantaActionPerformed
private void btn_spriteActionPerformed(java.awt.event.ActionEvent
evt) {//GEN-FIRST:event_btn_spriteActionPerformed

lbl_recoge.setIcon(latas[2]);
btn_seguir.setVisible(true);

btn_coca.setVisible(false);
btn_coca_light.setVisible(false);
btn_fanta.setVisible(false);
btn_manzana.setVisible(false);
btn_sangria.setVisible(false);
btn_sprite.setVisible(false);
btn_dibuja_automata.setVisible(true);

// TODO add your handling code here:


}//GEN-LAST:event_btn_spriteActionPerformed

private void btn_sangriaActionPerformed(java.awt.event.ActionEvent


evt) {//GEN-FIRST:event_btn_sangriaActionPerformed

lbl_recoge.setIcon(latas[3]);
btn_seguir.setVisible(true);

btn_coca.setVisible(false);
btn_coca_light.setVisible(false);
btn_fanta.setVisible(false);
btn_manzana.setVisible(false);
btn_sangria.setVisible(false);
btn_sprite.setVisible(false);
btn_dibuja_automata.setVisible(true);
// TODO add your handling code here:
}//GEN-LAST:event_btn_sangriaActionPerformed

private void btn_manzanaActionPerformed(java.awt.event.ActionEvent


evt) {//GEN-FIRST:event_btn_manzanaActionPerformed

lbl_recoge.setIcon(latas[4]);
btn_seguir.setVisible(true);

btn_coca.setVisible(false);
btn_coca_light.setVisible(false);
btn_fanta.setVisible(false);
btn_manzana.setVisible(false);
btn_sangria.setVisible(false);
btn_sprite.setVisible(false);
btn_dibuja_automata.setVisible(true);

// TODO add your handling code here:


}//GEN-LAST:event_btn_manzanaActionPerformed

private void btn_coca_lightActionPerformed(java.awt.event.ActionEvent


evt) {//GEN-FIRST:event_btn_coca_lightActionPerformed

lbl_recoge.setIcon(latas[5]);
btn_seguir.setVisible(true);
btn_coca.setVisible(false);
btn_coca_light.setVisible(false);
btn_fanta.setVisible(false);
btn_manzana.setVisible(false);
btn_sangria.setVisible(false);
btn_sprite.setVisible(false);
btn_dibuja_automata.setVisible(true);

// TODO add your handling code here:


}//GEN-LAST:event_btn_coca_lightActionPerformed

private void
btn_dibuja_automataActionPerformed(java.awt.event.ActionEvent evt)
{//GEN-FIRST:event_btn_dibuja_automataActionPerformed

btn_dibuja_automata.setVisible(false);

if(cadena.equals("aaaaaaaa")||cadena.equals("aaaaaaab")||
cadena.equals("aaaaaaac")||cadena.equals("aaaaaaad"))
{
dibuja.setIcon(automata[0]);
JFrame frame=new JFrame();
frame.setSize(500, 700);
frame.setVisible(true);
Component add = frame.add(dibuja);
}

if(cadena.equals("aaaaaab")||cadena.equals("aaaaaac")||
cadena.equals("aaaaaad"))
{
dibuja.setIcon(automata[1]);
JFrame frame=new JFrame();
frame.setSize(500, 700);
frame.setVisible(true);
Component add = frame.add(dibuja);
}

if(cadena.equals("aaaaac")||cadena.equals("aaaaad"))
{
dibuja.setIcon(automata[2]);
JFrame frame=new JFrame();
frame.setSize(500, 700);
frame.setVisible(true);
Component add = frame.add(dibuja);
}

if(cadena.equals("aaaac")||cadena.equals("aaaad"))
{
dibuja.setIcon(automata[3]);
JFrame frame=new JFrame();
frame.setSize(500, 700);
frame.setVisible(true);
Component add = frame.add(dibuja);
}

if(cadena.equals("aaac")||cadena.equals("aaad"))
{
dibuja.setIcon(automata[4]);
JFrame frame=new JFrame();
frame.setSize(500, 700);
frame.setVisible(true);
Component add = frame.add(dibuja);
}

if(cadena.equals("aad"))
{
dibuja.setIcon(automata[5]);
JFrame frame=new JFrame();
frame.setSize(500, 500);
frame.setVisible(true);
Component add = frame.add(dibuja);
}

if(cadena.equals("ad"))
{
dibuja.setIcon(automata[6]);
JFrame frame=new JFrame();
frame.setSize(500, 700);
frame.setVisible(true);
Component add = frame.add(dibuja);
}

if(cadena.equals("d"))
{
dibuja.setIcon(automata[7]);
JFrame frame=new JFrame();
frame.setSize(500, 700);
frame.setVisible(true);
Component add = frame.add(dibuja);
}

if(cadena.equals("abaaaaa")||cadena.equals("abaaaab")||
cadena.equals("abaaaac")||cadena.equals("abaaaad"))
{
dibuja.setIcon(automata[8]);
JFrame frame=new JFrame();
frame.setSize(500, 700);
frame.setVisible(true);
Component add = frame.add(dibuja);
}

if(cadena.equals("abbaaa")||cadena.equals("abbaab")||
cadena.equals("abbaac")||cadena.equals("abbaad"))
{
dibuja.setIcon(automata[9]);
JFrame frame=new JFrame();
frame.setSize(500, 700);
frame.setVisible(true);
Component add = frame.add(dibuja);
}

if(cadena.equals("ababaa")||cadena.equals("ababab")||
cadena.equals("ababac")||cadena.equals("ababad"))
{
dibuja.setIcon(automata[10]);
JFrame frame=new JFrame();
frame.setSize(500, 700);
frame.setVisible(true);
Component add = frame.add(dibuja);
}

if(cadena.equals("abaaba")||cadena.equals("abaabb")||
cadena.equals("abaabc")||cadena.equals("abaabd"))
{
dibuja.setIcon(automata[11]);
JFrame frame=new JFrame();
frame.setSize(500, 700);
frame.setVisible(true);
Component add = frame.add(dibuja);
}

if(cadena.equals("abaaab")||cadena.equals("abaaac")||
cadena.equals("abaaad"))
{
dibuja.setIcon(automata[12]);
JFrame frame=new JFrame();
frame.setSize(500, 700);
frame.setVisible(true);
Component add = frame.add(dibuja);
}

if(cadena.equals("aabbaa")||cadena.equals("aabbab")||
cadena.equals("aabbac")||cadena.equals("aabbad"))
{
dibuja.setIcon(automata[13]);
JFrame frame=new JFrame();
frame.setSize(500, 700);
frame.setVisible(true);
Component add = frame.add(dibuja);
}

if(cadena.equals("aababa")||cadena.equals("aababb")||
cadena.equals("aababc")||cadena.equals("aababd"))
{
dibuja.setIcon(automata[14]);
JFrame frame=new JFrame();
frame.setSize(500, 700);
frame.setVisible(true);
Component add = frame.add(dibuja);
}

if(cadena.equals("aabaab")||cadena.equals("aabaac")||
cadena.equals("aabaad"))
{
dibuja.setIcon(automata[15]);
JFrame frame=new JFrame();
frame.setSize(500, 700);
frame.setVisible(true);
Component add = frame.add(dibuja);
}
if(cadena.equals("aaabba")||cadena.equals("aaabbb")||
cadena.equals("aaabbc")||cadena.equals("aaabbd"))
{
dibuja.setIcon(automata[16]);
JFrame frame=new JFrame();
frame.setSize(500, 700);
frame.setVisible(true);
Component add = frame.add(dibuja);
}

if(cadena.equals("aaabab")||cadena.equals("aaabac")||
cadena.equals("aaabad"))
{
dibuja.setIcon(automata[17]);
JFrame frame=new JFrame();
frame.setSize(500, 700);
frame.setVisible(true);
Component add = frame.add(dibuja);
}

if(cadena.equals("abbba")||cadena.equals("abbbb")||
cadena.equals("abbbc")||cadena.equals("abbbd"))
{
dibuja.setIcon(automata[18]);
JFrame frame=new JFrame();
frame.setSize(500, 700);
frame.setVisible(true);
Component add = frame.add(dibuja);
}

if(cadena.equals("ababb")||cadena.equals("ababc")||
cadena.equals("ababd"))
{
dibuja.setIcon(automata[19]);
JFrame frame=new JFrame();
frame.setSize(500, 700);
frame.setVisible(true);
Component add = frame.add(dibuja);
}

if(cadena.equals("abbab")||cadena.equals("abbac")||
cadena.equals("abbad"))
{
dibuja.setIcon(automata[20]);
JFrame frame=new JFrame();
frame.setSize(500, 700);
frame.setVisible(true);
Component add = frame.add(dibuja);
}

if(cadena.equals("aabbb")||cadena.equals("aabbc")||
cadena.equals("aabbd"))
{
dibuja.setIcon(automata[21]);
JFrame frame=new JFrame();
frame.setSize(500, 700);
frame.setVisible(true);
Component add = frame.add(dibuja);
}

if(cadena.equals("acaa")||cadena.equals("acab")||
cadena.equals("acac")||cadena.equals("acad"))
{
dibuja.setIcon(automata[22]);
JFrame frame=new JFrame();
frame.setSize(500, 700);
frame.setVisible(true);
Component add = frame.add(dibuja);
}

if(cadena.equals("aaca")||cadena.equals("aacb")||
cadena.equals("aacc")||cadena.equals("aacd"))
{
dibuja.setIcon(automata[23]);
JFrame frame=new JFrame();
frame.setSize(500, 700);
frame.setVisible(true);
Component add = frame.add(dibuja);
}

if(cadena.equals("aaac")||cadena.equals("aaad"))
{
dibuja.setIcon(automata[24]);
JFrame frame=new JFrame();
frame.setSize(500, 700);
frame.setVisible(true);
Component add = frame.add(dibuja);
}

if(cadena.equals("acb")||cadena.equals("acc")||
cadena.equals("acd"))
{
dibuja.setIcon(automata[25]);
JFrame frame=new JFrame();
frame.setSize(500, 700);
frame.setVisible(true);
Component add = frame.add(dibuja);
}

if(cadena.equals("baaaaaa")||cadena.equals("baaaaab")||
cadena.equals("baaaaac")||cadena.equals("baaaaad"))
{
dibuja.setIcon(automata[26]);
JFrame frame=new JFrame();
frame.setSize(500, 700);
frame.setVisible(true);
Component add = frame.add(dibuja);
}

if(cadena.equals("bbaaaa")||cadena.equals("bbaaab")||
cadena.equals("bbaaac")||cadena.equals("bbaaad"))
{
dibuja.setIcon(automata[27]);
JFrame frame=new JFrame();
frame.setSize(500, 700);
frame.setVisible(true);
Component add = frame.add(dibuja);
}

if(cadena.equals("babaaa")||cadena.equals("babaab")||
cadena.equals("babaac")||cadena.equals("babaad"))
{
dibuja.setIcon(automata[28]);
JFrame frame=new JFrame();
frame.setSize(500, 700);
frame.setVisible(true);
Component add = frame.add(dibuja);
}

if(cadena.equals("baabaa")||cadena.equals("baabab")||
cadena.equals("baabac")||cadena.equals("baabad"))
{
dibuja.setIcon(automata[29]);
JFrame frame=new JFrame();
frame.setSize(500, 700);
frame.setVisible(true);
Component add = frame.add(dibuja);
}

if(cadena.equals("baaaba")||cadena.equals("baaabb")||
cadena.equals("baaabc")||cadena.equals("baaabd"))
{
dibuja.setIcon(automata[30]);
JFrame frame=new JFrame();
frame.setSize(500, 700);
frame.setVisible(true);
Component add = frame.add(dibuja);
}

if(cadena.equals("baaaab")||cadena.equals("baaaac")||
cadena.equals("baaaad"))
{
dibuja.setIcon(automata[31]);
JFrame frame=new JFrame();
frame.setSize(500, 700);
frame.setVisible(true);
Component add = frame.add(dibuja);
}

if(cadena.equals("bbbaa")||cadena.equals("bbbab")||
cadena.equals("bbbac")||cadena.equals("bbbad"))
{
dibuja.setIcon(automata[32]);
JFrame frame=new JFrame();
frame.setSize(500, 700);
frame.setVisible(true);
Component add = frame.add(dibuja);
}
if(cadena.equals("babba")||cadena.equals("babbb")||
cadena.equals("babbc")||cadena.equals("babbd"))
{
dibuja.setIcon(automata[33]);
JFrame frame=new JFrame();
frame.setSize(500, 700);
frame.setVisible(true);
Component add = frame.add(dibuja);
}

if(cadena.equals("baabb")||cadena.equals("baabc")||
cadena.equals("baabd"))
{
dibuja.setIcon(automata[34]);
JFrame frame=new JFrame();
frame.setSize(500, 700);
frame.setVisible(true);
Component add = frame.add(dibuja);
}

if(cadena.equals("bbbb"))
{
dibuja.setIcon(automata[35]);
JFrame frame=new JFrame();
frame.setSize(500, 700);
frame.setVisible(true);
Component add = frame.add(dibuja);
}

if(cadena.equals("bca")||cadena.equals("bcb")||
cadena.equals("bcc")||cadena.equals("bcd"))
{
dibuja.setIcon(automata[36]);
JFrame frame=new JFrame();
frame.setSize(500, 700);
frame.setVisible(true);
Component add = frame.add(dibuja);
}

if(cadena.equals("bd"))
{
dibuja.setIcon(automata[37]);
JFrame frame=new JFrame();
frame.setSize(500, 700);
frame.setVisible(true);
Component add = frame.add(dibuja);
}

if(cadena.equals("caaa")||cadena.equals("caab")||
cadena.equals("caac")||cadena.equals("caad"))
{
dibuja.setIcon(automata[38]);
JFrame frame=new JFrame();
frame.setSize(500, 700);
frame.setVisible(true);
Component add = frame.add(dibuja);
}
if(cadena.equals("cab")||cadena.equals("cac")||
cadena.equals("cad"))
{
dibuja.setIcon(automata[39]);
JFrame frame=new JFrame();
frame.setSize(500, 700);
frame.setVisible(true);
Component add = frame.add(dibuja);
}

if(cadena.equals("cba")||cadena.equals("cbb")||
cadena.equals("cbc"))
{
dibuja.setIcon(automata[40]);
JFrame frame=new JFrame();
frame.setSize(500, 700);
frame.setVisible(true);
Component add = frame.add(dibuja);
}

if(cadena.equals("cc")||cadena.equals("cd"))
{
dibuja.setIcon(automata[41]);
JFrame frame=new JFrame();
frame.setSize(500, 700);
frame.setVisible(true);
Component add = frame.add(dibuja);
}

if(cadena.equals("aaaabb")||cadena.equals("aaaabc")||
cadena.equals("aaaabd"))
{
dibuja.setIcon(automata[42]);
JFrame frame=new JFrame();
frame.setSize(500, 700);
frame.setVisible(true);
Component add = frame.add(dibuja);
}

// TODO add your handling code here:


}//GEN-LAST:event_btn_dibuja_automataActionPerformed

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Interfase().setVisible(true);
}
});
}

// Variables declaration - do not modify//GEN-BEGIN:variables


private javax.swing.JButton btn_10_pesos;
private javax.swing.JButton btn_1_peso;
private javax.swing.JButton btn_2_pesos;
private javax.swing.JButton btn_5_pesos;
private javax.swing.JButton btn_coca;
private javax.swing.JButton btn_coca_light;
private javax.swing.JButton btn_dibuja_automata;
private javax.swing.JButton btn_fanta;
private javax.swing.JButton btn_manzana;
private javax.swing.JButton btn_sangria;
private javax.swing.JButton btn_seguir;
private javax.swing.JButton btn_sprite;
private javax.swing.JButton btn_toma_y_recoge;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel lbl_cambio;
private javax.swing.JLabel lbl_dinero_maquina;
private javax.swing.JLabel lbl_ingresado;
private javax.swing.JLabel lbl_latas;
private javax.swing.JLabel lbl_recoge;
private javax.swing.JPanel pnl_recoge;
// End of variables declaration//GEN-END:variables

Al iniciar el programa esta será la primera pantalla que se nos mostrar, aquí es donde
ingresaremos el dinero para poder comprar una lata de refresco

Los datos de entrada son:

 El costo de la lata será de 8 pesos.


 El dinero total que la maquina tiene para dar cambio será de $300 pesos
 La maquina tendrá en su inventario un numero de 100 latas en total para venta
Una vez insertados los 8 pesos o una mayor cantidad a ese numero se habilitara el
boton para poder Tomar cambio y elegir refresco y aparecerán los botones para elegir el
refresco que hemos comprado, dándonos cambio si es que hemos insertado una cantidad
mayor al costo del refresco
Una vez que el refresco ha sido elegido nos encontraremos con dos opciones las
cuales son seguir comprando o dibujar el autómata.
Si elegimos seguir comprando de nuevo se habilitaran los botones para ingresar
dinero y se repetirá de nuevo todo el proceso.

Pero si elegimos dibujar el autómata nos abrirá una nueva pantalla la cual nos
indicara el camino que el autómata siguió en la inserción del dinero

También podría gustarte