App Email

package com.codemonkey.emailapp; import javax.swing.JOptionPane; public class Email{ private String firstName; private String lastName; private String password; private String department; private String email; private int mailboxCapacity; private int defaultPasswordLength = 10; private String alternativeEmail; private String companySuffix = ""; public Email(){} public Email(String firstName, String lastName){ this.firstName = firstName; this.lastName = lastName; System.out.println("El correo ha sido creado: "+firstName +" "+lastName); this.department = setDepartamento(); System.out.println("Departamento: "+this.department.toUpperCase()); this.password = randomPassword(defaultPasswordLength); System.out.println("Password: "+this.password); if("".equals(this.department)){ = firstName.toLowerCase()+"."+lastName.toLowerCase()+"@"+companySuffix; }else{ = firstName.toLowerCase()+"."+lastName.toLowerCase()+"@"+this.department+"."+companySuffix; } System.out.println("Email: "; } public void setMailboxCapacity(int capacity){ this.mailboxCapacity = capacity; } public int getMailboxCapacity(){ return mailboxCapacity; } public void setAlternativeEmail(String alernative){ this.alternativeEmail = alernative; } public String getAlternativeEmail(){ return alternativeEmail; } public void changePassword(String pass){ this.password = pass; } public String getPassword(){ return password; } private String setDepartamento(){ String opc = JOptionPane.showInputDialog("\n\tMenu\n1. Ventas\n2. Desarrollo\n3. Ninguno\nTu opcion es:"); String salida = ""; switch(opc){ case "1": salida = "ventas";break; case "2": salida = "desarrollo";break; case "3": salida = ""; break; default: salida = "";break; } return salida; } private String randomPassword(int tam){ String passwordSet = "ACDEFGHIJKLMÑOPQRSTUVWXYZ0123456789@!$#?"; char[] password = new char[tam]; for(int i=0; i < tam; i++){ int aleatorio = (int)(Math.random() * passwordSet.length()); password[i] = passwordSet.charAt(aleatorio); } return new String(password); } public String showInfo(){ return "\nNombre: "+firstName+" "+lastName +"\nEmail de la compañia: "+email +"\nCapacidad del mailbox: "+mailboxCapacity+"mb"; } }
Práctica en Udemy

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.