Código de Java - Tower of hanoi 3.1

Requerimientos

Original de NetBeans. utiliza la libreria swing.

3.1

Actualizado el 28 de Abril del 2020 (Publicado el 23 de Abril del 2020)gráfica de visualizaciones de la versión: 3.1
1.845 visualizaciones desde el 23 de Abril del 2020
estrellaestrellaestrellaestrellaestrella
estrellaestrellaestrellaestrella
estrellaestrellaestrella
estrellaestrella
estrella

Toda la parte visual esta terminada, pero hay fallos en la parte lógica.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
package prueba3.pkg1;
import java.awt.Color;
import javax.swing.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
/**
 *
 * @author msigl
 */
public class Logic2 {
 
    public int Entropy(int X, int m1, int m2, int m3,int x1, int x2, int x3, int y1, int y2, int y3){
 if((0 == m1)&&(0 == m2)&&(0 == m3)){
                if((X ==x1)){return 3;
                }else{ if((X - 25==x2)){return 2;
                }else{ if((X- 50 == x3)){return 1;
                }}}}
                if((1 == m1)||(1 == m2)||(1 == m3)){
                     if(1==m1){return 4;
                }else{ if(1==m2){return 5;
                }else{ if(1==m3){return 6;
                }}}}return 0;
}
public int Neguentropia(int X,int x1, int x2, int x3, int y1, int y2, int y3){
 
                if((((X !=x1)&&(400!=y1))||((X-25 !=x2)&&(400!=y2))||((X-50 !=x3)&&(400!=y3)))){return 400;
                }else{ if((((X !=x1)&&(340!=y1))||((X-25 !=x2)&&(340!=y2)))){return 340;
                }else{ if((280!=y1)&&(X != x1)){return 280;
                }}}return 0;
}
}
 
public class Prueba31 {
    private int X; private int Y;
    private String name;
 
    public class Pestañas extends JFrame{
      public  Pestañas(){
       super("new windows");
       setLayout(null);
       setSize(1920,1080);
       setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
      }
      public class Botones  extends JButton {
     public Botones(int X,int Y, String name ){
         super(name);
         setLayout(null);
         setBounds(X,Y,100,30);
         setVisible(true);
      }
     }
     public class BRicks extends JButton {
         int M;
     public BRicks(int X,int Y,int a, int l){
     setBounds(X,Y,a,l);
         setVisible(true);
          M = 0;
     }
     public void select(){
        M = M + 1;
     }
     public int getM(){
     return M;
     }
     public void setLo(int x, int y){
     setLocation(x,y);
     M = M - 1;
     }}
 
 
    /**
     * {}
     */
    public static void main(String[] args) {
   int YB1 = 490;
 
        Prueba31 pr = new Prueba31();
 
        Logic2 mind = new Logic2();
 
        Pestañas W1 = pr.new Pestañas();
 
          Botones B1 = pr.new Botones(650,YB1,"torre 1");
          Botones B2 = pr.new Botones(900,YB1,"torre 2");
          Botones B3 = pr.new Botones(1150,YB1,"torre 3");
 
 
          BRicks BL1 =  pr.new BRicks(650,280,100,60);
          BRicks BL2 =  pr.new BRicks(625,340,150,60);
          BRicks BL3 =  pr.new BRicks(600,400,200,60);
 
 
 
          BL1.setBackground(Color.red);BL2.setBackground(Color.green);BL3.setBackground(Color.blue);
 
        W1.setVisible(true);
        W1.add(B1); W1.add(B2);W1.add(B3);W1.add(BL1); W1.add(BL2);W1.add(BL3);
 
 
         ActionListener out1;
        out1 = (ActionEvent a) -> {
                 int X = 650;
                 int m1 = BL1.getM(); int m2 = BL2.getM();int m3 = BL3.getM();
                 int x1 = BL1.getX(); int x2 = BL2.getX();int x3 = BL3.getX();
                 int y1 = BL1.getY(); int y2 = BL2.getY();int y3 = BL3.getY();
                 int mi = mind.Entropy(X, m1, m2, m3, x1, x2, x3, y1, y2, y3);
                 int yi = mind.Neguentropia(X, x1, x2, x3, y1, y2, y3);
                 switch(mi){
                     case 1: BL3.select();
                     break;
                          case 2: BL2.select();
                     break;
                               case 3: BL1.select();
                     break;
                                    case 4: BL1.setLo(X, yi);
                     break;
                                         case 5: BL2.setLo(X-25, yi);
                     break;
                                              case 6: BL3.setLo(X-50, yi);
                     break;
                 }
   };
        ActionListener out2;
        out2 = new ActionListener(){
            public void actionPerformed(ActionEvent a){
                 int X = 900;
                 int m1 = BL1.getM(); int m2 = BL2.getM();int m3 = BL3.getM();
                 int x1 = BL1.getX(); int x2 = BL2.getX();int x3 = BL3.getX();
                 int y1 = BL1.getY(); int y2 = BL2.getY();int y3 = BL3.getY();
                  int mi = mind.Entropy(X, m1, m2, m3, x1, x2, x3, y1, y2, y3);
                   int yi = mind.Neguentropia(X, x1, x2, x3, y1, y2, y3);
                  switch(mi){
                     case 1: BL3.select();
                     break;
                          case 2: BL2.select();
                     break;
                               case 3: BL1.select();
                     break;
                                    case 4: BL1.setLo(X, yi);
                     break;
                                         case 5: BL2.setLo(X-25, yi);
                     break;
                                              case 6: BL3.setLo(X-50, yi);
                     break;
                 }
}};
        ActionListener out3;
        out3 = new ActionListener(){
            public void actionPerformed(ActionEvent a){
                 int X = 1150;
                 int m1 = BL1.getM(); int m2 = BL2.getM();int m3 = BL3.getM();
                 int x1 = BL1.getX(); int x2 = BL2.getX();int x3 = BL3.getX();
                 int y1 = BL1.getY(); int y2 = BL2.getY();int y3 = BL3.getY();
                   int mi =mind.Entropy(X, m1, m2, m3, x1, x2, x3, y1, y2, y3);
                    int yi = mind.Neguentropia(X, x1, x2, x3, y1, y2, y3);
                   switch(mi){
                     case 1: BL3.select();
                     break;
                          case 2: BL2.select();
                     break;
                               case 3: BL1.select();
                     break;
                                    case 4: BL1.setLo(X, yi);
                     break;
                                         case 5: BL2.setLo(X-25, yi);
                     break;
                                              case 6: BL3.setLo(X-50, yi);
                     break;
                 }
    }};
 
      B1.addActionListener(out1);
        B2.addActionListener(out2);
      B3.addActionListener(out3);
 
   }
    }



Comentarios sobre la versión: 3.1 (0)


No hay comentarios
 

Comentar la versión: 3.1

Nombre
Correo (no se visualiza en la web)
Valoración
Comentarios...
CerrarCerrar
CerrarCerrar
Cerrar

Tienes que ser un usuario registrado para poder insertar imágenes, archivos y/o videos.

Puedes registrarte o validarte desde aquí.

Codigo
Negrita
Subrayado
Tachado
Cursiva
Insertar enlace
Imagen externa
Emoticon
Tabular
Centrar
Titulo
Linea
Disminuir
Aumentar
Vista preliminar
sonreir
dientes
lengua
guiño
enfadado
confundido
llorar
avergonzado
sorprendido
triste
sol
estrella
jarra
camara
taza de cafe
email
beso
bombilla
amor
mal
bien
Es necesario revisar y aceptar las políticas de privacidad

http://lwp-l.com/s6148