Iteración 3(Versión sin idiomas)
[ISBets21MAUBRY] / eclipse-workspace / ISBets21MAUBRY / src / main / java / gui / RegisterGUI.java
1 package gui;
2
3 import java.awt.Color;
4 import java.awt.Font;
5 import java.awt.Frame;
6 import java.awt.event.ActionEvent;
7 import java.awt.event.ActionListener;
8 import java.text.ParseException;
9 import java.text.SimpleDateFormat;
10 import java.time.LocalDate;
11 import java.time.ZoneId;
12 import java.util.Calendar;
13 import java.util.Date;
14 import java.util.regex.Matcher;
15 import java.util.regex.Pattern;
16
17 import javax.swing.JButton;
18 import javax.swing.JFrame;
19 import javax.swing.JLabel;
20 import javax.swing.JOptionPane;
21 import javax.swing.JPasswordField;
22 import javax.swing.JTextField;
23 import javax.swing.SwingConstants;
24
25 import businessLogic.BLFacade;
26 import domain.RegularUser;
27 import domain.User;
28 import javax.swing.ImageIcon;
29 import java.awt.SystemColor;
30
31 public class RegisterGUI extends JFrame {
32         private JLabel lblNombre;
33         private JLabel lblApellidos;
34         private JLabel lblFechaNacimiento;
35         private JLabel lblEmail;
36         private JLabel lblCuentaBancaria;
37         private JLabel lblTelfono;
38         private JLabel lblDireccin;
39         private JTextField textUser;
40         private JTextField textName;
41         private JTextField textLastName;
42         private JTextField textBirth;
43         private JTextField textEmail;
44         private JTextField textBank;
45         private JTextField textPhoneNumber;
46         private JTextField textAddress;
47         private JPasswordField textPass;
48         private static BLFacade facade = LoginGUI.getBusinessLogic();
49         private static User user;
50         JButton buttonRegistrarse = new JButton("Registrarse");
51         private JButton btnAtras;
52         private JLabel lblInfoNombre;
53         private JLabel lblInfoNombre_1;
54         private JLabel lblIcono2;
55         private JLabel lblInfoDir;
56
57         public RegisterGUI() {
58                 getContentPane().setBackground(Color.WHITE);
59                 try {
60                         initialize();
61                 } catch (Exception e) {
62                         e.printStackTrace();
63                 }
64         }
65
66         public static void setBusinessLogic(BLFacade pfacade) {
67                 facade = pfacade;
68         }
69
70         public static BLFacade getBusinessLogic() {
71                 return facade;
72         }
73
74         public void initialize() throws ParseException {
75                 setTitle("Registro");
76                 getContentPane().setLayout(null);
77                 setBounds(100, 100, 763, 450);
78                 setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
79
80                 JLabel lblUser = new JLabel("Usuario:");
81                 lblUser.setBounds(5, 55, 100, 14);
82                 lblUser.setFont(new Font("Tahoma", Font.PLAIN, 13));
83                 lblUser.setHorizontalAlignment(SwingConstants.RIGHT);
84                 getContentPane().add(lblUser);
85
86                 JLabel lblUser_1 = new JLabel("Contraseña:");
87                 lblUser_1.setBounds(5, 84, 100, 14);
88                 lblUser_1.setHorizontalAlignment(SwingConstants.RIGHT);
89                 lblUser_1.setFont(new Font("Tahoma", Font.PLAIN, 13));
90                 getContentPane().add(lblUser_1);
91
92                 lblNombre = new JLabel("Nombre:");
93                 lblNombre.setBounds(285, 56, 100, 14);
94                 lblNombre.setHorizontalAlignment(SwingConstants.RIGHT);
95                 lblNombre.setFont(new Font("Tahoma", Font.PLAIN, 13));
96                 getContentPane().add(lblNombre);
97
98                 lblApellidos = new JLabel("Apellidos:");
99                 lblApellidos.setBounds(285, 96, 100, 14);
100                 lblApellidos.setHorizontalAlignment(SwingConstants.RIGHT);
101                 lblApellidos.setFont(new Font("Tahoma", Font.PLAIN, 13));
102                 getContentPane().add(lblApellidos);
103
104                 lblFechaNacimiento = new JLabel("Fecha nacimiento:");
105                 lblFechaNacimiento.setBounds(268, 133, 117, 14);
106                 lblFechaNacimiento.setHorizontalAlignment(SwingConstants.RIGHT);
107                 lblFechaNacimiento.setFont(new Font("Tahoma", Font.PLAIN, 13));
108                 getContentPane().add(lblFechaNacimiento);
109
110                 lblEmail = new JLabel("Email:");
111                 lblEmail.setBounds(285, 173, 100, 14);
112                 lblEmail.setHorizontalAlignment(SwingConstants.RIGHT);
113                 lblEmail.setFont(new Font("Tahoma", Font.PLAIN, 13));
114                 getContentPane().add(lblEmail);
115
116                 lblCuentaBancaria = new JLabel("Cuenta bancaria:");
117                 lblCuentaBancaria.setBounds(285, 213, 100, 14);
118                 lblCuentaBancaria.setHorizontalAlignment(SwingConstants.RIGHT);
119                 lblCuentaBancaria.setFont(new Font("Tahoma", Font.PLAIN, 13));
120                 getContentPane().add(lblCuentaBancaria);
121
122                 lblTelfono = new JLabel("Teléfono:");
123                 lblTelfono.setBounds(285, 252, 100, 14);
124                 lblTelfono.setHorizontalAlignment(SwingConstants.RIGHT);
125                 lblTelfono.setFont(new Font("Tahoma", Font.PLAIN, 13));
126                 getContentPane().add(lblTelfono);
127
128                 lblDireccin = new JLabel("Dirección:");
129                 lblDireccin.setBounds(285, 292, 100, 14);
130                 lblDireccin.setHorizontalAlignment(SwingConstants.RIGHT);
131                 lblDireccin.setFont(new Font("Tahoma", Font.PLAIN, 13));
132                 getContentPane().add(lblDireccin);
133
134                 textUser = new JTextField();
135                 textUser.setBounds(115, 51, 131, 20);
136                 textUser.setFont(new Font("Liberation Sans", Font.PLAIN, 13));
137                 textUser.setColumns(10);
138                 getContentPane().add(textUser);
139
140                 textName = new JTextField();
141                 textName.setBounds(395, 55, 131, 20);
142                 textName.setFont(new Font("Liberation Sans", Font.PLAIN, 13));
143                 textName.setColumns(10);
144                 getContentPane().add(textName);
145
146                 textLastName = new JTextField();
147                 textLastName.setBounds(395, 95, 131, 20);
148                 textLastName.setFont(new Font("Liberation Sans", Font.PLAIN, 13));
149                 textLastName.setColumns(10);
150                 getContentPane().add(textLastName);
151
152                 textBirth = new JTextField();
153                 textBirth.setBounds(395, 132, 131, 20);
154                 textBirth.setFont(new Font("Liberation Sans", Font.PLAIN, 13));
155                 textBirth.setColumns(10);
156                 getContentPane().add(textBirth);
157
158                 textEmail = new JTextField();
159                 textEmail.setBounds(395, 172, 159, 20);
160                 textEmail.setFont(new Font("Liberation Sans", Font.PLAIN, 13));
161                 textEmail.setColumns(10);
162                 getContentPane().add(textEmail);
163
164                 textBank = new JTextField();
165                 textBank.setBounds(395, 212, 153, 20);
166                 textBank.setFont(new Font("Liberation Sans", Font.PLAIN, 13));
167                 textBank.setColumns(10);
168                 getContentPane().add(textBank);
169
170                 textPhoneNumber = new JTextField();
171                 textPhoneNumber.setBounds(395, 251, 131, 20);
172                 textPhoneNumber.setFont(new Font("Liberation Sans", Font.PLAIN, 13));
173                 textPhoneNumber.setColumns(10);
174                 getContentPane().add(textPhoneNumber);
175
176                 textAddress = new JTextField();
177                 textAddress.setBounds(395, 291, 227, 20);
178                 textAddress.setFont(new Font("Liberation Sans", Font.PLAIN, 13));
179                 textAddress.setColumns(10);
180                 getContentPane().add(textAddress);
181
182                 textPass = new JPasswordField();
183                 textPass.setBounds(115, 82, 131, 19);
184                 textPass.setFont(new Font("Liberation Sans", Font.PLAIN, 13));
185                 textPass.setColumns(10);
186                 getContentPane().add(textPass);
187                 buttonRegistrarse.setForeground(Color.WHITE);
188                 buttonRegistrarse.setBackground(SystemColor.textHighlight);
189                 buttonRegistrarse.setFont(new Font("Dialog", Font.BOLD, 14));
190
191                 buttonRegistrarse.setBounds(440, 348, 140, 23);
192                 getContentPane().add(buttonRegistrarse);
193
194                 JLabel lblNewLabel = new JLabel("dd/mm/aaaa");
195                 lblNewLabel.setForeground(Color.GRAY);
196                 lblNewLabel.setFont(new Font("Tahoma", Font.BOLD | Font.ITALIC, 11));
197                 lblNewLabel.setBounds(530, 132, 79, 16);
198                 getContentPane().add(lblNewLabel);
199
200                 JLabel lblEsxxXxxxXxxx = new JLabel("ESXX XXXX XXXX XXXX ");
201                 lblEsxxXxxxXxxx.setFont(new Font("Tahoma", Font.BOLD | Font.ITALIC, 11));
202                 lblEsxxXxxxXxxx.setForeground(Color.GRAY);
203                 lblEsxxXxxxXxxx.setBounds(553, 212, 146, 16);
204                 getContentPane().add(lblEsxxXxxxXxxx);
205
206                 JLabel lblXxxxxxxxx = new JLabel("(+34) XXXXXXXXX");
207                 lblXxxxxxxxx.setForeground(Color.GRAY);
208                 lblXxxxxxxxx.setFont(new Font("Tahoma", Font.BOLD | Font.ITALIC, 11));
209                 lblXxxxxxxxx.setBounds(530, 251, 146, 16);
210                 getContentPane().add(lblXxxxxxxxx);
211
212                 JLabel lblAlMenos = new JLabel("Al menos:");
213                 lblAlMenos.setForeground(Color.GRAY);
214                 lblAlMenos.setFont(new Font("Tahoma", Font.BOLD | Font.ITALIC, 12));
215
216                 lblAlMenos.setBounds(81, 113, 146, 16);
217                 getContentPane().add(lblAlMenos);
218
219                 JLabel lblCaracteres = new JLabel("8 caracteres");
220                 lblCaracteres.setForeground(Color.GRAY);
221                 lblCaracteres.setFont(new Font("Tahoma", Font.BOLD | Font.ITALIC, 10));
222
223                 lblCaracteres.setBounds(101, 133, 146, 16);
224                 getContentPane().add(lblCaracteres);
225
226                 JLabel lblUnaMayscula = new JLabel("Una mayúscula");
227                 lblUnaMayscula.setForeground(Color.GRAY);
228                 lblUnaMayscula.setFont(new Font("Tahoma", Font.BOLD | Font.ITALIC, 10));
229
230                 lblUnaMayscula.setBounds(101, 152, 146, 16);
231                 getContentPane().add(lblUnaMayscula);
232
233                 JLabel lblUnaMin = new JLabel("Una minúscula");
234                 lblUnaMin.setForeground(Color.GRAY);
235                 lblUnaMin.setFont(new Font("Tahoma", Font.BOLD | Font.ITALIC, 10));
236
237                 // lblUnaMin.setFont(new Font("Dialog", Font.BOLD, 10));
238                 lblUnaMin.setBounds(102, 171, 146, 16);
239                 getContentPane().add(lblUnaMin);
240
241                 JLabel lblUnNmero = new JLabel("Un número");
242                 lblUnNmero.setForeground(Color.GRAY);
243                 lblUnNmero.setFont(new Font("Tahoma", Font.BOLD | Font.ITALIC, 10));
244
245                 // lblUnNmero.setFont(new Font("Dialog", Font.BOLD, 10));
246                 lblUnNmero.setBounds(101, 190, 146, 16);
247                 getContentPane().add(lblUnNmero);
248
249                 JLabel lblUnCaracterEspecial = new JLabel("Un caracter especial");
250                 lblUnCaracterEspecial.setForeground(Color.GRAY);
251                 lblUnCaracterEspecial.setFont(new Font("Tahoma", Font.BOLD | Font.ITALIC, 10));
252
253                 // lblUnCaracterEspecial.setFont(new Font("Dialog", Font.BOLD, 10));
254                 lblUnCaracterEspecial.setBounds(101, 208, 146, 16);
255                 getContentPane().add(lblUnCaracterEspecial);
256
257                 JLabel lblSinEspaciosEn = new JLabel("Sin espacios en blanco");
258                 lblSinEspaciosEn.setForeground(Color.GRAY);
259                 lblSinEspaciosEn.setFont(new Font("Tahoma", Font.BOLD | Font.ITALIC, 10));
260
261                 // lblSinEspaciosEn.setFont(new Font("Dialog", Font.BOLD, 10));
262                 lblSinEspaciosEn.setBounds(101, 229, 146, 16);
263                 getContentPane().add(lblSinEspaciosEn);
264
265                 JLabel lblgmailcom = new JLabel("debe ser @gmail.com");
266                 lblgmailcom.setForeground(Color.GRAY);
267                 lblgmailcom.setFont(new Font("Tahoma", Font.BOLD | Font.ITALIC, 11));
268
269                 // lblgmailcom.setFont(new Font("Dialog", Font.BOLD, 12));
270                 lblgmailcom.setBounds(559, 174, 146, 16);
271                 getContentPane().add(lblgmailcom);
272
273                 btnAtras = new JButton("Atrás");
274                 btnAtras.setBackground(SystemColor.controlShadow);
275                 btnAtras.setForeground(Color.WHITE);
276                 btnAtras.setFont(new Font("Dialog", Font.BOLD, 14));
277                 btnAtras.addActionListener(new ActionListener() {
278                         @Override
279                         public void actionPerformed(ActionEvent e) {
280
281 //                              Frame reg = new LoginGUI();
282 //                              reg.setAlwaysOnTop(true);
283 //                              reg.setVisible(true);
284                                 dispose();
285
286                         }
287                 });
288                 btnAtras.setBounds(54, 348, 79, 23);
289                 getContentPane().add(btnAtras);
290
291                 JLabel lblIcono = new JLabel(" ");
292                 lblIcono.setIcon(new ImageIcon("C:\\Users\\Bryan\\Desktop\\Workspace\\ISBets21BRYMAUJONUNA\\info.png"));
293                 lblIcono.setBounds(54, 106, 30, 30);
294                 getContentPane().add(lblIcono);
295
296                 lblInfoNombre = new JLabel("Sin números");
297                 lblInfoNombre.setFont(new Font("Tahoma", Font.BOLD | Font.ITALIC, 11));
298                 lblInfoNombre.setForeground(Color.GRAY);
299                 lblInfoNombre.setBounds(530, 55, 95, 16);
300                 getContentPane().add(lblInfoNombre);
301
302                 lblInfoNombre_1 = new JLabel("Sin números");
303                 lblInfoNombre_1.setForeground(Color.GRAY);
304                 lblInfoNombre_1.setFont(new Font("Tahoma", Font.BOLD | Font.ITALIC, 11));
305                 lblInfoNombre_1.setBounds(530, 95, 95, 16);
306                 getContentPane().add(lblInfoNombre_1);
307
308                 ImageIcon icon = new ImageIcon("imagenes/info.png");
309                 lblIcono2 = new JLabel(icon);
310                 lblIcono2.setBounds(640, 284, 30, 30);
311                 getContentPane().add(lblIcono2);
312         
313                 
314                 lblInfoDir = new JLabel("Opcional");
315                 lblInfoDir.setBounds(665, 291, 55, 16);
316                 lblInfoDir.setFont(new Font("Tahoma", Font.BOLD | Font.ITALIC, 12));
317                 lblInfoDir.setForeground(Color.GRAY);
318
319                 getContentPane().add(lblInfoDir);
320                 buttonRegistrarse.addActionListener(new ActionListener() {
321                         @SuppressWarnings("deprecation")
322                         @Override
323                         public void actionPerformed(ActionEvent e) {
324
325                                 try {
326                                         boolean control = true;
327                                         if (textUser.getText().equals("")) {
328                                                 JOptionPane.showMessageDialog(getContentPane(), "Introduce un nombre de usuario",
329                                                                 "Error", JOptionPane.ERROR_MESSAGE);
330                                                 control = false;
331
332                                         }
333
334                                         if (validoNombre(textName.getText()) == false) {
335                                                 textName.setText("");
336
337                                                 JOptionPane.showMessageDialog(getContentPane(), "Nombre con solo letras", "Error",
338                                                                 JOptionPane.ERROR_MESSAGE);
339                                                 control = false;
340
341                                         }
342
343                                         if (validoNombre(textLastName.getText()) == false) {
344                                                 textLastName.setText("");
345
346                                                 JOptionPane.showMessageDialog(getContentPane(), "Apellidos con solo letras", "Error",
347                                                                 JOptionPane.ERROR_MESSAGE);
348                                                 control = false;
349
350                                         }
351
352                                         if (validofecha(textBirth.getText()) == false) {
353                                                 JOptionPane.showMessageDialog(getContentPane(), "Fecha incorrecta", "Error",
354                                                                 JOptionPane.ERROR_MESSAGE);
355                                                 control = false;
356
357                                         }
358
359                                         if (validoEmail(textEmail.getText()) == false) {
360                                                 JOptionPane.showMessageDialog(getContentPane(), "Email incorrecto", "Error",
361                                                                 JOptionPane.ERROR_MESSAGE);
362                                                 control = false;
363
364                                         }
365
366                                         if (validoContraseña(textPass.getText()) == false) {
367                                                 JOptionPane.showMessageDialog(getContentPane(), "Contraseña incorrecta", "Error",
368                                                                 JOptionPane.ERROR_MESSAGE);
369                                                 control = false;
370
371                                         }
372                                         if (textBank.getText().equals("")) {
373
374                                                 control = true;
375                                         } 
376                                         else if (validoCuentaB(textBank.getText()) == false) {
377                                                 JOptionPane.showMessageDialog(getContentPane(), "Cuenta Bancaria incorrecta", "Error",
378                                                                 JOptionPane.ERROR_MESSAGE);
379                                                 control = false;
380
381                                         }
382                                         if (validoNumero(textPhoneNumber.getText()) == false) {
383                                                 JOptionPane.showMessageDialog(getContentPane(), "Numero de teléfono incorrecto", "Error",
384                                                                 JOptionPane.ERROR_MESSAGE);
385                                                 control = false;
386
387                                         }
388
389                                         if (control) {
390                                                 facade.registrar(textUser.getText(), textPass.getText(), textName.getText(),
391                                                                 textLastName.getText(), textBirth.getText(), textEmail.getText(), textBank.getText(),
392                                                                 Integer.parseInt(textPhoneNumber.getText()), textAddress.getText(), 0);
393                                                 JOptionPane.showMessageDialog(getContentPane(), "Registrado correctamente el usuario: "
394                                                                 + textUser.getText() + "\n\nSerá redirigido al apartado para loguearse...");
395
396                                                 JOptionPane.showMessageDialog(getContentPane(),
397                                                                 "ENHORABUENA!!!!!\nTe regalamos un bono de bienvenida de 5€ para que apuestes");
398                                                 facade.aplicarBonoBienvenida(textUser.getText());
399                                                 dispose();
400                                         }
401
402                                 } catch (exceptions.UserAlreadyExistException ex) {
403
404                                         JOptionPane.showMessageDialog(getContentPane(), ex.getMessage(), "Error",
405                                                         JOptionPane.ERROR_MESSAGE);
406                                 }
407
408                                 catch (Exception o) {
409                                         o.printStackTrace();
410
411                                 }
412
413                         }
414
415                 });
416
417         }
418
419         /* *************************************************************** */
420         /* FUNCIONES AUXILIARES DE COMPROBACIÓN DE CAMPOS PARA EL REGISTRO */
421         /* *************************************************************** */
422
423         // se verifica que el nombre sea solo formado por letras o espacios en blanco,
424         // tambien usado para apellidos
425         private boolean validoNombre(String nombre) {
426                 int longitud = nombre.toCharArray().length;
427
428                 for (int i = 0; i < longitud; i++) {
429                         if (!Character.isLetter(nombre.toCharArray()[i]) && !Character.isWhitespace(nombre.toCharArray()[i])) {
430                                 return false;
431                         }
432                 }
433
434                 return true;
435         }
436
437         // se verifica que la fecha sea valida
438         private boolean validofecha(String pfecha) {
439                 try {
440
441                         String[] parts = pfecha.split("\\/"); // se divide el string pfecha en partes separadas por un /
442                         if (parts.length != 3) { // se verifica que se el array surgido tiene tres elementos XX/XX/XXXX, sino
443                                                                                 // devuelve false
444                                 return false;
445                         } else {
446                                 int year; // año
447                                 int month; // mes [1,...,12]
448                                 int dayOfMonth; // día [1,...,31]
449                                 dayOfMonth = Integer.parseInt(parts[0]); // se parsea a int la primera parte XX/xx/xxxx, de string a int
450                                 month = Integer.parseInt(parts[1]); // se parsea a int la segunda parte xx/XX/xxxx, de string a int
451                                 year = Integer.parseInt(parts[2]); // se parsea a int la tercera parte xx/xx/XXXX, de string a int
452                                 if (year < 1900) { // se verifica que el año sea mayor a 1900
453                                         throw new IllegalArgumentException("Año inválido.");
454                                 }
455
456                                 Calendar calendar = Calendar.getInstance(); // se combierte la fecha en un Calendar, que automaticamente
457                                 calendar.setLenient(false); // si al intentarlo no puede, lanza excepcion como fecha
458                                 calendar.set(Calendar.YEAR, year); // no valida
459                                 calendar.set(Calendar.MONTH, month - 1); // [0,...,11] (la clase Calendar trata asi los meses 0-11)
460                                 calendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
461                                 Date date = calendar.getTime(); // date es la fecha en formato Calendar XXXX/XX/XX
462                                 Date date2 = Date.from(LocalDate.now().atStartOfDay(ZoneId.systemDefault()).toInstant()); // fecha
463                                                                                                                                                                                                                         // actual en
464                                                                                                                                                                                                                         // formato
465                                                                                                                                                                                                                         // Date
466                                 if (date.after(date2)) { // se verifica que la fecha introducida no es posterior a la actual
467                                         System.out.println("FECHA POSTERIOR A HOY");
468                                         throw new IllegalArgumentException("Año inválido.");
469
470                                 }
471                                 SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); // se transforma la fecha formato Calendar a
472                                                                                                                                                         // formato Date
473                                 System.out.println(sdf.format(date)); // dd/MM/yyyy //es decir, de XXXX/XX/XX a XX/XX/XXXX
474                                 System.out.println("Fecha validada");
475                                 System.out.println("La fecha actual es: " + LocalDate.now());
476                                 return true;
477                         }
478
479                 } catch (Exception p) {
480                         System.out.println("FECHA NO VALIDA");
481                         return false;
482                 }
483
484         }
485
486         private boolean validoEmail(String email) {
487                 Pattern pattern = Pattern.compile("^[a-zA-Z0-9]+((\\_|\\.)[a-zA-Z0-9]+)?@gmail\\.com$");
488                 Matcher mat = pattern.matcher(email);
489                 if (mat.matches()) {
490                         System.out.println("Porfin metes un email correscto estupida");
491
492                 } else {
493                         System.out.println("Amiga que email de meirda es ese");
494                         return false;
495                 }
496                 return true;
497         }
498
499         public static boolean validoContraseña(String contraseña) {
500                 Pattern pattern = Pattern.compile("^(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%^&?+=])(?=\\S+$).{8,}$");
501                 Matcher mat = pattern.matcher(contraseña);
502                 if (mat.matches()) {
503                         System.out.println("Porfin metes una contraseña correcta estupida");
504
505                 } else {
506                         System.out.println("Amiga que contraseña de mierda es esa");
507                         return false;
508                 }
509                 return true;
510         }
511
512         // acepta cuentas bancarias del tipo: ES23 3434 2342 3423
513         private boolean validoCuentaB(String cuentab) {
514                 Pattern pattern = Pattern.compile("^[A-Z]{2}[0-9]{2}\\s[0-9]{4}\\s[0-9]{4}\\s[0-9]{4}$");
515                 Matcher mat = pattern.matcher(cuentab);
516                 if (mat.matches()) {
517                         System.out.println("El formato de la cuenta bancaria cumple el formato");
518                 } else {
519                         System.out.println("El formato de la cuenta bancaria es incorrecto");
520                         return false;
521                 }
522                 return true;
523         }
524
525         // +34(opcional) 123456789
526         private boolean validoNumero(String numero) {
527                 Pattern pattern = Pattern.compile("^(\\+[0-9]+\\s)?[0-9]{9}$");
528                 Matcher mat = pattern.matcher(numero);
529                 if (mat.matches()) {
530                         System.out.println("El formato del numero de telefono cumple el formato");
531                 } else {
532                         System.out.println("El formato del numero de telofono es incorrecto");
533                         return false;
534                 }
535                 return true;
536         }
537 }