|
1 | | -package emailgenerator; |
| 1 | +package Email_App; |
2 | 2 |
|
3 | 3 | import java.util.Scanner; |
4 | 4 |
|
5 | | -public class EmailBackProgram { |
6 | | -private String firstname; |
7 | | -private String lastname; |
| 5 | +public class Email { |
| 6 | +private String firstName; |
| 7 | +private String lastName; |
8 | 8 | private String password; |
9 | 9 | private String department; |
10 | 10 | private String email; |
11 | | -private int mailboxCapacity = 500; |
12 | | -private int defaultPasswordLength = 10; |
13 | | -private String alternateEmail; |
14 | | -private String companySuffix = "xyzemail.com"; |
15 | | - |
16 | | -public EmailBackProgram(String firstname, String lastname) { |
17 | | -this.firstname = firstname; |
18 | | -this.lastname = lastname; |
19 | | - |
20 | | -this.department = setDepartment(); |
21 | | - |
22 | | -this.password = randomPassword(defaultPasswordLength); |
23 | | -System.out.println("Your Password is: " + this.password); |
24 | | - |
25 | | -email = firstname.toLowerCase() + "." + lastname.toLowerCase() + "@" + department + "." + companySuffix; |
26 | | -} |
27 | | - |
28 | | -private String setDepartment() { |
29 | | -System.out.print("Welcome!! " + firstname + "."+" You are Our New Employee." + " \nChoose Department Codes\n1 C++\n2 Java\n3 Python\n0 None\nEnter Department Code: "); |
30 | | -Scanner in = new Scanner(System.in); |
31 | | -int depChoice = in.nextInt(); |
32 | | -if(depChoice == 1) {return "C++";} |
33 | | -else if(depChoice == 2) {return "Java";} |
34 | | -else if(depChoice == 3) {return "Python";} |
35 | | -else {return "";} |
| 11 | +private int defaultPasswordLength=8; |
| 12 | +private int codelen=5; |
| 13 | +private String Vcode; |
| 14 | +private String company="drngpit.ac.in"; |
| 15 | +private String name; |
| 16 | + |
| 17 | +public Email(String firstName, String lastName) { |
| 18 | +this.firstName = firstName; |
| 19 | +this.lastName = lastName; |
| 20 | +System.out.println("Kindly ! Enter department for email creation dear "+this.firstName+" "+this.lastName); |
| 21 | +//dept |
| 22 | +this.department=setDepartment(); |
| 23 | +System.out.println("Department:"+department); |
| 24 | +//pass |
| 25 | +this.password=randomPass(defaultPasswordLength); |
| 26 | +System.out.println("New Password :"+password); |
| 27 | +//clipping name as one |
| 28 | +this.name=firstName+lastName; |
| 29 | +//verification code |
| 30 | +this.Vcode=vcode(codelen); |
| 31 | +System.out.println("Your verification code : "+Vcode); |
| 32 | + |
| 33 | +//Binding |
| 34 | +email=name.toLowerCase()+"."+department+"@"+company; |
| 35 | +System.out.println("Official mail :"+email); |
36 | 36 | } |
37 | | -
|
38 | | -private String randomPassword(int length) { |
39 | | -String passwordSet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%&*^"; |
40 | | -char [] password = new char[length]; |
41 | | -for(int i = 0; i<length;i++) { |
42 | | -int rand = (int)(Math.random()*passwordSet.length()); |
43 | | -password[i] = passwordSet.charAt(rand); |
| 37 | + |
| 38 | +private String setDepartment(){ |
| 39 | +System.out.println("Enter the department Id\nSales : 1\nDevelopment : 2\nAccounting : 3"); |
| 40 | +Scanner in=new Scanner(System.in); |
| 41 | +int dep=in.nextInt(); |
| 42 | +if(dep==1){ |
| 43 | +return "sales"; |
44 | 44 | } |
45 | | -return new String(password); |
| 45 | +else if(dep==2){ |
| 46 | +return"dev"; |
| 47 | +} |
| 48 | +else if(dep==3){ |
| 49 | +return "acc"; |
| 50 | +} |
| 51 | +return""; |
46 | 52 | } |
47 | | - |
48 | | -public void setMailboxCapacity(int capacity) { |
49 | | -this.mailboxCapacity = capacity; |
| 53 | + |
| 54 | +private String randomPass(int length){ |
| 55 | +String password="ABCEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%"; |
| 56 | +char[]pass=new char[length]; |
| 57 | +for(int i=0;i<length;i++){ |
| 58 | +int rand=(int)(Math.random()*password.length()); |
| 59 | +pass[i]=password.charAt(rand); |
| 60 | +} |
| 61 | +return new String(pass); |
50 | 62 | } |
51 | | - |
52 | | -public void setAlternateEmail(String altEmail) { |
53 | | -this.alternateEmail = altEmail; |
| 63 | +private String vcode(int codelen){ |
| 64 | +String samcode="1234567890"; |
| 65 | +char[]code=new char[codelen]; |
| 66 | +for(int i=0;i<codelen;i++){ |
| 67 | +int c=(int)(Math.random()*samcode.length()); |
| 68 | +code[i]=samcode.charAt(c); |
| 69 | +} |
| 70 | +return new String(code); |
54 | 71 | } |
55 | | -
|
56 | | -public void changePassword(String password) { |
| 72 | + |
| 73 | +public void setPassword(String password) { |
57 | 74 | this.password = password; |
58 | 75 | } |
59 | | - |
60 | | -public int getMailboxCapacity() {return mailboxCapacity;} |
61 | | -public String getAlternateEmail() {return alternateEmail;} |
62 | | -public String getPassword() {return password;} |
63 | | - |
64 | | -public String showInfo() { |
65 | | -return "Display Name: " + firstname + " " + lastname + |
66 | | -"\nCompany Email: " + email + |
67 | | -"\nMailbox Capacity: " + mailboxCapacity + "mb"; |
| 76 | + |
| 77 | +public String getDepartment() { |
| 78 | +return department; |
| 79 | +} |
| 80 | + |
| 81 | +public void setDepartment(String department) { |
| 82 | +this.department = department; |
| 83 | +} |
| 84 | + |
| 85 | +public String getEmail() { |
| 86 | +return email; |
| 87 | +} |
| 88 | + |
| 89 | +public void setEmail(String email) { |
| 90 | +this.email = email; |
| 91 | +} |
| 92 | + |
| 93 | + |
| 94 | +public String getPassword(){ |
| 95 | +return password; |
| 96 | +} |
| 97 | + |
| 98 | +public String getFirstName() { |
| 99 | +return firstName; |
| 100 | +} |
| 101 | + |
| 102 | +public void setFirstName(String firstName) { |
| 103 | +this.firstName = firstName; |
| 104 | +} |
| 105 | + |
| 106 | +public String getVcode() { |
| 107 | +return Vcode; |
| 108 | +} |
| 109 | +public String getDept(String dep){ |
| 110 | +if(dep.equals("dev")){ |
| 111 | +return "Developers"; |
| 112 | +} |
| 113 | +else if(dep.equals("acc")){ |
| 114 | +return "Accounts"; |
| 115 | +} |
| 116 | +else if(dep.equals("sales")){ |
| 117 | +return "Sales"; |
| 118 | +} |
| 119 | +return ""; |
| 120 | + |
| 121 | +} |
| 122 | +public String showInfo(){ |
| 123 | +return "Name : "+name+"\nOfficial email : "+email+"\nDepartment : "+getDept(department); |
68 | 124 | } |
69 | 125 | } |
0 commit comments