Skip to content

Commit 00152f4

Browse files
Merge pull request #445 from gokulnathanT/gokul
Contributed to Email Administration system - By Gokul
2 parents 8c06292 + e9f3678 commit 00152f4

File tree

2 files changed

+174
-60
lines changed

2 files changed

+174
-60
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,125 @@
1-
package emailgenerator;
1+
package Email_App;
22

33
import java.util.Scanner;
44

5-
public class EmailBackProgram {
6-
private String firstname;
7-
private String lastname;
5+
public class Email {
6+
private String firstName;
7+
private String lastName;
88
private String password;
99
private String department;
1010
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);
3636
}
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";
4444
}
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"";
4652
}
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);
5062
}
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);
5471
}
55-
56-
public void changePassword(String password) {
72+
73+
public void setPassword(String password) {
5774
this.password = password;
5875
}
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);
68124
}
69125
}
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,69 @@
1-
package emailgenerator;
1+
package Email_App;
22

3-
public class EmailMainProgram {
3+
import com.sun.security.jgss.GSSUtil;
44

5+
import java.sql.SQLOutput;
6+
import java.util.Scanner;
7+
8+
public class EmailApp {
59
public static void main(String[] args) {
6-
EmailBackProgram email = new EmailBackProgram("Abhinandan", "Raj");
7-
System.out.println(email.showInfo());
10+
System.out.println("Generate Organization's Email ==>");
11+
Scanner sc=new Scanner(System.in);
812

9-
}
13+
// String x=sc.nextLine();
14+
System.out.println("Generating the email...");
15+
System.out.println("Enter firstname :");
16+
String first=sc.nextLine();
17+
System.out.println("Enter Lastname :");
18+
String second=sc.nextLine();
1019

11-
}
20+
Email em=new Email(first,second);
21+
22+
while(true) {
23+
System.out.println("1 : Information ");
24+
System.out.println("2 : Change Email");
25+
System.out.println("3 : Change Password");
26+
System.out.println("4 : Disclose Password");
27+
System.out.println("5 : Exit");
28+
System.out.println("Enter operation code :");
29+
int a = sc.nextInt();
30+
switch (a) {
31+
case 1:
32+
System.out.println(em.showInfo());
33+
break;
34+
case 2:
35+
System.out.println("Enter alternate email prefix :");
36+
sc.nextLine();
37+
String alt = sc.nextLine();
38+
em.setEmail(alt+"@drngpit.ac.in");
39+
break;
40+
case 3:
41+
System.out.println("Enter the verification code :");
42+
sc.nextLine();
43+
String s = sc.nextLine();
44+
if (s.equals(em.getVcode())) {
45+
System.out.println("Enter alternate password :");
46+
String p = sc.nextLine();
47+
em.setPassword(p);
48+
} else {
49+
System.out.println("Please Enter valid verification code !!!");
50+
}
51+
System.out.println("Password updated successfully !!!");
52+
break;
53+
case 4:
54+
System.out.println("Password disclose warning !!!");
55+
System.out.println("Enter the verification code :");
56+
sc.nextLine();
57+
String s1 = sc.nextLine();
58+
if (s1.equals(em.getVcode())) {
59+
System.out.println("Your password : " + em.getPassword());
60+
} else {
61+
System.out.println("Please Enter valid verification code !!!");
62+
}
63+
case 5:
64+
System.out.println("Have a great day ahead ! BYE ");
65+
return ;
66+
}
67+
}
68+
}
69+
}

0 commit comments

Comments
 (0)