Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- en agragr jugador interfase
- private void jbtnAbrirActionPerformed(java.awt.event.ActionEvent evt) {
- int i;
- if (Persistencia.agregarJugadores(jFileChooser1.getSelectedFile(), s, false)) {
- i = JOptionPane.showConfirmDialog(this, "Hay jugadores con mismo alias, desea actualizar los jugadores?.", "Actualizar?.", JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE);
- if (i == JOptionPane.YES_OPTION) {
- Persistencia.actualizarJugadores(jFileChooser1.getSelectedFile(), s);
- JOptionPane.showMessageDialog(this, "Se han actualizado los jugadores. ", "Jugadores Actualizados.", JOptionPane.INFORMATION_MESSAGE);
- } else if (i == JOptionPane.NO_OPTION) {
- JOptionPane.showMessageDialog(this, "No se actualizo ", "Nope.", JOptionPane.INFORMATION_MESSAGE);
- }
- } else {
- JOptionPane.showMessageDialog(this, "Se han agregado los jugadores. ", "Jugadores Agregados.", JOptionPane.INFORMATION_MESSAGE);
- }
- }
- en clase persistencia
- public static void actualizarJugadores(File archivo, Sistema s) {
- ArchivoLectura al1 = new ArchivoLectura(archivo.getPath());
- while (al1.hayMasLineas()) {
- String lineaActual = al1.linea();
- String[] contenido = lineaActual.split("@");
- Jugador j = new Jugador();
- j.setNombre(contenido[0]);
- j.setAlias(contenido[1]);
- int edad;
- edad = Integer.parseInt(contenido[2]);
- j.setEdad(edad);
- for (int i = 0; i < s.getJugadores().size(); i++) {
- if (s.getJugadores().get(i).getAlias().equals(j.getAlias())) {
- s.getJugadores().get(i).setNombre(j.getNombre());
- s.getJugadores().get(i).setEdad(j.getEdad());
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement