-
Notifications
You must be signed in to change notification settings - Fork 467
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Contributed to Email Administration system - By Gokul
- Loading branch information
1 parent
8c06292
commit e9f3678
Showing
2 changed files
with
174 additions
and
60 deletions.
There are no files selected for viewing
164 changes: 110 additions & 54 deletions
164
Email_Generator/src/emailgenerator/EmailBackProgram.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,125 @@ | ||
package emailgenerator; | ||
package Email_App; | ||
|
||
import java.util.Scanner; | ||
|
||
public class EmailBackProgram { | ||
private String firstname; | ||
private String lastname; | ||
public class Email { | ||
private String firstName; | ||
private String lastName; | ||
private String password; | ||
private String department; | ||
private String email; | ||
private int mailboxCapacity = 500; | ||
private int defaultPasswordLength = 10; | ||
private String alternateEmail; | ||
private String companySuffix = "xyzemail.com"; | ||
|
||
public EmailBackProgram(String firstname, String lastname) { | ||
this.firstname = firstname; | ||
this.lastname = lastname; | ||
|
||
this.department = setDepartment(); | ||
|
||
this.password = randomPassword(defaultPasswordLength); | ||
System.out.println("Your Password is: " + this.password); | ||
|
||
email = firstname.toLowerCase() + "." + lastname.toLowerCase() + "@" + department + "." + companySuffix; | ||
} | ||
|
||
private String setDepartment() { | ||
System.out.print("Welcome!! " + firstname + "."+" You are Our New Employee." + " \nChoose Department Codes\n1 C++\n2 Java\n3 Python\n0 None\nEnter Department Code: "); | ||
Scanner in = new Scanner(System.in); | ||
int depChoice = in.nextInt(); | ||
if(depChoice == 1) {return "C++";} | ||
else if(depChoice == 2) {return "Java";} | ||
else if(depChoice == 3) {return "Python";} | ||
else {return "";} | ||
private int defaultPasswordLength=8; | ||
private int codelen=5; | ||
private String Vcode; | ||
private String company="drngpit.ac.in"; | ||
private String name; | ||
|
||
public Email(String firstName, String lastName) { | ||
this.firstName = firstName; | ||
this.lastName = lastName; | ||
System.out.println("Kindly ! Enter department for email creation dear "+this.firstName+" "+this.lastName); | ||
//dept | ||
this.department=setDepartment(); | ||
System.out.println("Department:"+department); | ||
//pass | ||
this.password=randomPass(defaultPasswordLength); | ||
System.out.println("New Password :"+password); | ||
//clipping name as one | ||
this.name=firstName+lastName; | ||
//verification code | ||
this.Vcode=vcode(codelen); | ||
System.out.println("Your verification code : "+Vcode); | ||
|
||
//Binding | ||
email=name.toLowerCase()+"."+department+"@"+company; | ||
System.out.println("Official mail :"+email); | ||
} | ||
private String randomPassword(int length) { | ||
String passwordSet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%&*^"; | ||
char [] password = new char[length]; | ||
for(int i = 0; i<length;i++) { | ||
int rand = (int)(Math.random()*passwordSet.length()); | ||
password[i] = passwordSet.charAt(rand); | ||
|
||
private String setDepartment(){ | ||
System.out.println("Enter the department Id\nSales : 1\nDevelopment : 2\nAccounting : 3"); | ||
Scanner in=new Scanner(System.in); | ||
int dep=in.nextInt(); | ||
if(dep==1){ | ||
return "sales"; | ||
} | ||
return new String(password); | ||
else if(dep==2){ | ||
return"dev"; | ||
} | ||
else if(dep==3){ | ||
return "acc"; | ||
} | ||
return""; | ||
} | ||
|
||
public void setMailboxCapacity(int capacity) { | ||
this.mailboxCapacity = capacity; | ||
|
||
private String randomPass(int length){ | ||
String password="ABCEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%"; | ||
char[]pass=new char[length]; | ||
for(int i=0;i<length;i++){ | ||
int rand=(int)(Math.random()*password.length()); | ||
pass[i]=password.charAt(rand); | ||
} | ||
return new String(pass); | ||
} | ||
|
||
public void setAlternateEmail(String altEmail) { | ||
this.alternateEmail = altEmail; | ||
private String vcode(int codelen){ | ||
String samcode="1234567890"; | ||
char[]code=new char[codelen]; | ||
for(int i=0;i<codelen;i++){ | ||
int c=(int)(Math.random()*samcode.length()); | ||
code[i]=samcode.charAt(c); | ||
} | ||
return new String(code); | ||
} | ||
public void changePassword(String password) { | ||
|
||
public void setPassword(String password) { | ||
this.password = password; | ||
} | ||
|
||
public int getMailboxCapacity() {return mailboxCapacity;} | ||
public String getAlternateEmail() {return alternateEmail;} | ||
public String getPassword() {return password;} | ||
|
||
public String showInfo() { | ||
return "Display Name: " + firstname + " " + lastname + | ||
"\nCompany Email: " + email + | ||
"\nMailbox Capacity: " + mailboxCapacity + "mb"; | ||
|
||
public String getDepartment() { | ||
return department; | ||
} | ||
|
||
public void setDepartment(String department) { | ||
this.department = department; | ||
} | ||
|
||
public String getEmail() { | ||
return email; | ||
} | ||
|
||
public void setEmail(String email) { | ||
this.email = email; | ||
} | ||
|
||
|
||
public String getPassword(){ | ||
return password; | ||
} | ||
|
||
public String getFirstName() { | ||
return firstName; | ||
} | ||
|
||
public void setFirstName(String firstName) { | ||
this.firstName = firstName; | ||
} | ||
|
||
public String getVcode() { | ||
return Vcode; | ||
} | ||
public String getDept(String dep){ | ||
if(dep.equals("dev")){ | ||
return "Developers"; | ||
} | ||
else if(dep.equals("acc")){ | ||
return "Accounts"; | ||
} | ||
else if(dep.equals("sales")){ | ||
return "Sales"; | ||
} | ||
return ""; | ||
|
||
} | ||
public String showInfo(){ | ||
return "Name : "+name+"\nOfficial email : "+email+"\nDepartment : "+getDept(department); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,69 @@ | ||
package emailgenerator; | ||
package Email_App; | ||
|
||
public class EmailMainProgram { | ||
import com.sun.security.jgss.GSSUtil; | ||
|
||
import java.sql.SQLOutput; | ||
import java.util.Scanner; | ||
|
||
public class EmailApp { | ||
public static void main(String[] args) { | ||
EmailBackProgram email = new EmailBackProgram("Abhinandan", "Raj"); | ||
System.out.println(email.showInfo()); | ||
System.out.println("Generate Organization's Email ==>"); | ||
Scanner sc=new Scanner(System.in); | ||
|
||
} | ||
// String x=sc.nextLine(); | ||
System.out.println("Generating the email..."); | ||
System.out.println("Enter firstname :"); | ||
String first=sc.nextLine(); | ||
System.out.println("Enter Lastname :"); | ||
String second=sc.nextLine(); | ||
|
||
} | ||
Email em=new Email(first,second); | ||
|
||
while(true) { | ||
System.out.println("1 : Information "); | ||
System.out.println("2 : Change Email"); | ||
System.out.println("3 : Change Password"); | ||
System.out.println("4 : Disclose Password"); | ||
System.out.println("5 : Exit"); | ||
System.out.println("Enter operation code :"); | ||
int a = sc.nextInt(); | ||
switch (a) { | ||
case 1: | ||
System.out.println(em.showInfo()); | ||
break; | ||
case 2: | ||
System.out.println("Enter alternate email prefix :"); | ||
sc.nextLine(); | ||
String alt = sc.nextLine(); | ||
em.setEmail(alt+"@drngpit.ac.in"); | ||
break; | ||
case 3: | ||
System.out.println("Enter the verification code :"); | ||
sc.nextLine(); | ||
String s = sc.nextLine(); | ||
if (s.equals(em.getVcode())) { | ||
System.out.println("Enter alternate password :"); | ||
String p = sc.nextLine(); | ||
em.setPassword(p); | ||
} else { | ||
System.out.println("Please Enter valid verification code !!!"); | ||
} | ||
System.out.println("Password updated successfully !!!"); | ||
break; | ||
case 4: | ||
System.out.println("Password disclose warning !!!"); | ||
System.out.println("Enter the verification code :"); | ||
sc.nextLine(); | ||
String s1 = sc.nextLine(); | ||
if (s1.equals(em.getVcode())) { | ||
System.out.println("Your password : " + em.getPassword()); | ||
} else { | ||
System.out.println("Please Enter valid verification code !!!"); | ||
} | ||
case 5: | ||
System.out.println("Have a great day ahead ! BYE "); | ||
return ; | ||
} | ||
} | ||
} | ||
} |