-
Notifications
You must be signed in to change notification settings - Fork 0
/
Employ.java
151 lines (132 loc) · 2.72 KB
/
Employ.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
package com.empmodule;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.LinkedHashSet;
import java.util.Set;
public class Employ
{
private int id;
private String name;
private String lname;
private Date dob;
private String address;
private String gender;
private String department;
private long phno;
private String skills;
@SuppressWarnings("unused")
private int age;
boolean setSuccess=false;
// private Set<String> skills = new LinkedHashSet<String>();
public String getSkills()
{
return skills;
}
public void setSkills(String skills)
{
this.skills = skills;
}
public String getDepartment()
{
return department;
}
public void setDepartment(String department)
{
this.department = department;
}
public int getId() //getter method restricts direct access
{
return this.id; //current object id
}
public long getPhno()
{
return phno;
}
public void setPhno(long phno)
{
this.phno = phno;
}
public String getName()
{
return name.toUpperCase();
}
public String getLname()
{
return lname.toUpperCase();
}
public String getDob()
{
SimpleDateFormat formatter = new SimpleDateFormat("dd-MMM-yyyy");
return formatter.format(dob);
}
public String getDob(int a)
{
SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy");
return formatter.format(dob);
}
public String getAddress()
{
return address.toUpperCase();
}
public String getGender()
{
return gender.toUpperCase();
}
// ------------------------- SETTERS --------------------------------------------------
public boolean setID(int id) //setter method prevent data mis-handling
{
if(id>0)
{
this.id=id;
return true;
}
else
{
System.err.println("ID cannot be negative or zero");
return false;
}
}
public void setName(String name) //setter method prevent data mis-handling
{
this.name=name;
}
public void setLname(String name)
{
this.lname=name;
}
public void setDOB(String dob)
{
SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy");
try
{
this.dob=formatter.parse(dob);
}
catch (ParseException e)
{
System.out.println("Enter date in proper Format -> dd-MM-yyyy");
return;
}
setSuccess=true;
}
public void setDOB(Date dob)
{
this.dob=dob;
}
public void setGender(String gender)
{
this.gender=gender;
}
public void setAddress(String address)
{
this.address=address;
}
public int getAge()
{
return Math.abs(dob.getYear()-new Date().getYear());
}
public void setAge(int age)
{
this.age=age;
}
}