Generation

fix invalid codeThu, 23 Mar 2023

package zoologic; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.ArrayList; import javax.swing.*; public class DeptoLogistica extends JFrame implements ActionListener { private final ArrayList<Animal> animal = new ArrayList<>(); // Creamos un ArrayList para almacenar los animales private int totalVentasBoletos = 0; private int totalVentasPremium = 0; private double totalVentasAnimales = 0; private final JButton btnBoletos, btnPremium, btnAnimal, btnListar, btnSalir; private final JLabel lblTitulo, lblAcumulado; private final JTextArea txtAreaAnimales; private final JPanel panel; public DeptoLogistica() { super("Zoologico SADY"); setSize(400, 400); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setLocationRelativeTo(null); panel = new JPanel(null); lblTitulo = new JLabel("Bienvenidos al Zoologico SADY"); lblTitulo.setBounds(100, 20, 200, 20); panel.add(lblTitulo); btnBoletos = new JButton("Caja registradora - Boletos"); btnBoletos.setBounds(100, 50, 200, 30); btnBoletos.addActionListener(this); panel.add(btnBoletos); btnPremium = new JButton("Caja registradora - Premium"); btnPremium.setBounds(100, 90, 200, 30); btnPremium.addActionListener(this); panel.add(btnPremium); btnAnimal = new JButton("Registrar venta de animales"); btnAnimal.setBounds(100, 130, 200, 30); btnAnimal.addActionListener(this); panel.add(btnAnimal); btnListar = new JButton("Listado de animales"); btnListar.setBounds(100, 170, 200, 30); btnListar.addActionListener(this); panel.add(btnListar); btnSalir = new JButton("Salir"); btnSalir.setBounds(100, 210, 200, 30); btnSalir.addActionListener(this); panel.add(btnSalir); lblAcumulado = new JLabel("Total acumulado: $0"); lblAcumulado.setBounds(100, 250, 200, 20); panel.add(lblAcumulado); txtAreaAnimales = new JTextArea(); txtAreaAnimales.setBounds(50, 280, 300, 70); txtAreaAnimales.setEditable(false); panel.add(txtAreaAnimales); add(panel); setVisible(true); } public static void main(String[] args) { new DeptoLogistica(); } @Override public void actionPerformed(ActionEvent e) { switch (e.getActionCommand()) { case "Caja registradora - Boletos": int cantidadBoletos = Integer.parseInt(JOptionPane.showInputDialog(null, "Ingrese la cantidad de boletos vendidos:")); totalVentasBoletos += cantidadBoletos; break; case "Caja registradora - Premium": int cantidadPremium = Integer.parseInt(JOptionPane.showInputDialog(null, "Ingrese la cantidad de entradas premium vendidas:")); totalVentasPremium += cantidadPremium; break; case "Registrar venta de animales": String nombre = JOptionPane.showInputDialog(null, "Ingrese el nombre del animal:"); String especie = JOptionPane.showInputDialog(null, "Ingrese la especie del animal:"); double precio = Double.parseDouble(JOptionPane.showInputDialog(null, "Ingrese el precio del animal:"));

private final JButton btnBoletos, btnPremium, btnAnimal, btnListar, btnSalir;

Questions about programming?Chat with your personal AI assistant