dejavxtrem
9/13/2019 - 3:42 PM

Email Administration Application

Email Administration Application

package EmailApp;

import sun.java2d.windows.GDIWindowSurfaceData;

import java.util.Scanner;

public class Email {
    private String firstName;
    private String lastName;
    private String password;
    private String department;
    private int mailboxCapacity;
    private int defaultPasswordLength = 10;
    private String alternativeEmail;
    private String email;
    private int Capacity = 500;
    private String suffix = "dejavu.com";

    //constructor the receive the first name and last name
    // Ask the department
    //Generate  a random password
   //set the mailbox capacity
   // change the password
   public Email (String firstName, String lastName) {
      this.firstName = firstName;
      this.lastName = lastName;
     // System.out.println("Email Created: " + this.firstName + this.lastName);
      this.department = setDepartment();
      //System.out.println("Department: " + this.department);
      this.password = randomPassword(defaultPasswordLength);
      System.out.println("Your Password is:" + this.password);
      email = firstName.toLowerCase() + "." + lastName.toLowerCase() + "@" + department + "." + suffix;
      //System.out.println("Your Email is:" + email);
}


     //Generate Random Password

    private String randomPassword (int length) {
        String passwordGenerator = "ABCDEFGHIJKLMNOPQRSTUVWXYZZ1234567890@!$";
        char[] newPassword = new char[length];
        for (int i = 0; i < length; i++) {
            int read = (int) (Math.random() * passwordGenerator.length());
            newPassword[i] = passwordGenerator.charAt(read);
        }
        return new String(newPassword);
    }

    public void setEmailCapacity (int capacityMail) {
       this.Capacity = capacityMail;
    }

    public  void setEmail(String altEmail) {
        this.alternativeEmail = altEmail;
    }

    public void changePassword(String newPassword) {
        this.password = newPassword;
    }
    public int getEmailCapacity () {return Capacity;}
    public String getAltEmail() {return alternativeEmail;}
    public String getNewPassword() {return password;}

    public String showInfo() {
       return "Display Name: " + " " + firstName + " " + lastName + " \n" +
              "Company Email: " +  email + suffix + "\n" +
               "Mailbox Capacity: " + Capacity + "mb";

    }

    private String  setDepartment(){
        System.out.print("New worker: " +  firstName+ ". DEPARTMENT CODES\n1 for Sales\n2 for Development\n3 for Accounting\n0 for none\nEnter department code:");
        Scanner in = new Scanner(System.in);
        int departmentChoice = in.nextInt();
        if (departmentChoice == 1) {
            return "Sales";
        } else if (departmentChoice == 2) {
            return "Development";
        } else if (departmentChoice == 3) {
            return "Accounting";
        } else { return "";}
   }













}