-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEmail.java
88 lines (71 loc) · 2.48 KB
/
Email.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package Emailapp;
import java.util.Scanner;
public class Email {
private String firstname;
private String lastname;
private String password;
private String department;
private String email;
private int mailboxcapacity = 300;
private String alternateEmail;
private int defaultpasswordLength=12;
private String uniname = "bauhausuni.de";
public Email(String firstname, String lastname) {
this.firstname = firstname;
this.lastname = lastname;
System.out.println(" your name is" +"" + this.firstname+" "+ this.lastname);
// method for department
this.department = setDepartment();
System.out.println("Departmnet" + " " +this.department);
// set random password
this.password = randomPassword(defaultpasswordLength);
System.out.println("password is:" + " ");
// creating email by combining first and last name
email = firstname.toLowerCase()+"."+lastname.toLowerCase()+"@"+department+uniname;
System.out.println("new email is" + " " + email);
}
// email assigned according to the department;
private String setDepartment() {
System.out.println(" your department\n1 DE\n2 CS4DM\n3 HCI" );
Scanner in = new Scanner(System.in);
int choice=in.nextInt();
if (choice ==1 ) {return "DE";}
else if(choice == 2) {return "CS4DM";}
else if (choice == 3) {return "HCI";}
else {return "Bauhaus University Weimar ";}
}
private String randomPassword(int length){
String passwords ="ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*()_+,./:";
char[] password =new char[length];
for (int i=0; i< length; i++) {int rand =
(int)Math.random()* passwords.length();
password[i]= passwords.charAt(rand);
System.out.println(rand);
System.out.println(passwords.charAt(rand));
}
return new String(password);
}
// mail box capacity
public void setmailboxcapacity(int capacity) {
this.mailboxcapacity = capacity;
}
// alternate email address
public void setalternatemail(String altmail) {
this.alternateEmail= altmail;
}
// change password
public void changePassword(String password) {
this.password = password;
}
public int getmailboxcapacity() {
return mailboxcapacity;
}
public String getalternateemail() {
return alternateEmail;
}
public String getpassword() { return password;}
public String Info() {
return " Name:"+firstname + " " + lastname + " " +
"UNIVERSITY:" + uniname + " mail:"+email + "mailbox capacity:" +mailboxcapacity;
}
}