From 12b85df405b1396ed854ba7abc3614c25b12b9c5 Mon Sep 17 00:00:00 2001 From: David Date: Fri, 15 Mar 2024 19:47:59 -0600 Subject: [PATCH] =?UTF-8?q?Funcionalidad=20de=20selecci=C3=B3n=20de=20asie?= =?UTF-8?q?nto=20completa?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- GestiónBotónSeleccionarAsiento.java | 6 ++-- SeleccionarAsientoV.java | 27 ++++++++++++++++-- .../GestiónBotónSeleccionarAsiento.class | Bin 1451 -> 1445 bytes .../mezontleTeam/SeleccionarAsientoV.class | Bin 4970 -> 5447 bytes 4 files changed, 29 insertions(+), 4 deletions(-) diff --git a/GestiónBotónSeleccionarAsiento.java b/GestiónBotónSeleccionarAsiento.java index c7cafc0..26677a9 100644 --- a/GestiónBotónSeleccionarAsiento.java +++ b/GestiónBotónSeleccionarAsiento.java @@ -1,7 +1,9 @@ import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; -public class GestiónBotónSeleccionarAsiento implements ChangeListener { +public class GestiónBotónSeleccionarAsiento implements ActionListener { private Asiento asiento; private SeleccionarAsientoV ventana; public GestiónBotónSeleccionarAsiento(Asiento parAsiento, SeleccionarAsientoV parVentana) { @@ -10,7 +12,7 @@ public class GestiónBotónSeleccionarAsiento implements ChangeListener { } @Override - public void stateChanged(ChangeEvent e) { + public void actionPerformed(ActionEvent e) { System.out.println("i:" + asiento.getX() + " j:" + asiento.getY()); ventana.seleccionarAsientos(asiento); } diff --git a/SeleccionarAsientoV.java b/SeleccionarAsientoV.java index b6cbaae..3db563e 100644 --- a/SeleccionarAsientoV.java +++ b/SeleccionarAsientoV.java @@ -1,8 +1,11 @@ import javax.swing.*; import java.awt.*; +import java.util.ArrayList; +import java.util.List; public class SeleccionarAsientoV extends JPanel { + JPanel panel; private JPanel pSuperior = new JPanel(new FlowLayout(FlowLayout.LEFT)); private JButton bRegresar = new JButton("Regresar."); private int noAsientosSeleccionados = 0; @@ -19,13 +22,15 @@ public class SeleccionarAsientoV extends JPanel { private Asiento [][] asientos; - + List asientosSeleccionados = new ArrayList(); public SeleccionarAsientoV(Asiento [][] parAsientos) throws HeadlessException { this.setLayout(new BorderLayout()); asientos = parAsientos; agregarComponentes(); + añadirListeners(); + crearCeldas(7,10); } @@ -73,7 +78,7 @@ public class SeleccionarAsientoV extends JPanel { } tfAux.setSize(100,100); //tfAux.addKeyListener(new GestiónTecladoEscribirCaracter(this,i,j)); - tfAux.addChangeListener(new GestiónBotónSeleccionarAsiento(new Asiento(i,j,zona,asientos[i][j].isDisponibilidad()),this)); + tfAux.addActionListener(new GestiónBotónSeleccionarAsiento(new Asiento(i,j,zona,asientos[i][j].isDisponibilidad()),this)); con.gridx = j; con.gridy = i; con.gridheight = 1; @@ -88,6 +93,10 @@ public class SeleccionarAsientoV extends JPanel { this.add(pSala,BorderLayout.CENTER); } + public void añadirListeners(){ + //bRegresar.addActionListener(new GestiónBotónCambiarVentana(this,new ventana2().panelV2)); + } + public void seleccionarAsientos(Asiento asiento){ int precio = 0; @@ -112,14 +121,28 @@ public class SeleccionarAsientoV extends JPanel { if (bAsientos[x][y].isSelected()) { noAsientosSeleccionados++; total += precio; + asientosSeleccionados.add(asiento); } else { noAsientosSeleccionados--; total -= precio; + + for(int a = 0; a < asientosSeleccionados.size() ;a++){ + if(asientosSeleccionados.get(a).equals(asiento)){ + asientosSeleccionados.remove(a); + } + } + } }else{ bAsientos[x][y].setSelected(false); } + System.out.print("["); + for(int a = 0; a < asientosSeleccionados.size() ;a++){ + System.out.print(asientosSeleccionados.get(a).getX() + " " + asientosSeleccionados.get(a).getY() + ", " ); + } + System.out.println("]"); + lSeleccionar.setText("Asientos seleccionados: " + noAsientosSeleccionados); lTotal.setText("Total: " + total + "$"); } diff --git a/out/production/mezontleTeam/GestiónBotónSeleccionarAsiento.class b/out/production/mezontleTeam/GestiónBotónSeleccionarAsiento.class index a9f3d46510c6447da3509b8e0d11e3f4a5e2621d..fe1da11cc537e39523c89bde5f3a73fa7eb10beb 100644 GIT binary patch delta 151 zcmZ3@y_9>yTShV2ti-ZJ{lxMT{nWD5yb^uK_j LDhxuC(^*{rDv~Xr delta 157 zcmZ3=y_$Q&TSiHRti-a!3jN~p%)E5{)UwpP5`E{4#Ju#>$;?cPf_REc5=&Ac0x66P zN*X@6l)HkoT5E3jl`XFXjLM diff --git a/out/production/mezontleTeam/SeleccionarAsientoV.class b/out/production/mezontleTeam/SeleccionarAsientoV.class index 7903efeff1967b2dfbba56c6f9cde1294e5548a0..88ac2b56bce2d9341de9ad4d241121e5b295a3b2 100644 GIT binary patch literal 5447 zcmaJ_31AfE75@IcX0r@rSy&)k1_+WYM=(f~1kfZvh=fA|!GKgJ$&hT=?8e;*5bA|e ztF>Bh#HvNq;!)eGWK+OWtJPB5T6<{iVXgMEhrKVAO20R=yGck|$jpDe_x|_Z|GoFW z*_S>%dK^HNst&*fw+4?6FMJB24r7P0t2DJU8gDDTV4V>+V+y{-(RkEas^BgzY1H6X z7$an*#!jnrMJ%zi-snkmTLEYYh?o%yp5nTaMiD(yCPpbtDz4A5IOMC1xY1@ND@z*l z5X5K=Asu5dma-ennAy@2O~j34RVr%6twf_jUROhRmzj(vk_uyOS%bB#)G#iiS8k!Y z+p-dIKPHfUz1fyDQ$})L0AWlNttKgiGg`$ATH9bHX>>-PDLSU&4DvN+8A&~OTSt1O zXg^KIbj(l~A5Ua7PW2nnnn)?AIt?>VcW=GXY{o)7hgmv`Q9}MsW4l?Ch_@Klrl{4< zUdl4!7Wu<;sN=zbx&}~$iK4(99dj{HL67zCJJeD3ezwB%b(|%>&g-g+Z?nBBQWoeq zTg>oU3Co~j3bSPT93AJ1a9?bL%==NHFk-+yLbF)M67iSbJYYe?c?#ol=U$tPwpJT$ zS+p#LTR5wA)QBqHt_CA!Xjq;_SGN_7l~yH_Mo)b-MRYB5=vV5f!v*w+;b7x*PX`@0 z+1$cNVAPX3r$u!l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