-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDemo.java
167 lines (132 loc) · 4.65 KB
/
Demo.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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
class D {
private int dd = 0;
private int mm = 0;
private int yyyy = 0;
public void setDate(int dd, int mm, int yyyy) {
this.dd = dd;
this.mm = mm;
this.yyyy = yyyy;
}
public String getDate() {
String currentDate = dd + "/" + mm + "/" + yyyy;
return currentDate;
}
}
class Student {
private String nameOfStudent;
private int studentId;
private String nameOfCourse;
private D dateOfAdmission;
public Student() {
this.nameOfStudent = "";
this.studentId = 1000;
this.nameOfCourse = "Java FSD";
this.dateOfAdmission = new D();
this.dateOfAdmission.setDate(01, 01, 1995);
}
public Student(String nameOfStudent, int studentId, String nameOfCourse, int dd, int mm, int yyyy) {
this.nameOfStudent = nameOfStudent;
this.studentId = studentId;
this.nameOfCourse = nameOfCourse;
this.dateOfAdmission = new D();
this.dateOfAdmission.setDate(dd, mm, yyyy);
}
public void setNameOfStudent(String nameOfStudent) {
this.nameOfStudent = nameOfStudent;
}
public String getNameOfStudent() {
return this.nameOfStudent;
}
public void setStudentId(int studentId) {
this.studentId = studentId;
}
public int getStudentId() {
return studentId;
}
public void setNameOfCourse(String nameOfCourse) {
this.nameOfCourse = nameOfCourse;
}
public String getNameOfCourse() {
return nameOfCourse;
}
public void setDateOfAdmission(int dd, int mm, int yyyy) {
this.dateOfAdmission.setDate(dd, mm, yyyy);
}
public String getDateOfAdmission() {
String dateOfAdmission = this.dateOfAdmission.getDate();
return dateOfAdmission;
}
public void printStudentInformation() {
System.out.print("Name of Student: ");
System.out.println(this.getNameOfStudent());
System.out.print("Student ID: ");
System.out.println(this.getStudentId());
System.out.print("Name of Course: ");
System.out.println(this.getNameOfCourse());
System.out.print("Date of Admission: ");
System.out.println(this.getDateOfAdmission());
}
}
class Employee {
private String nameOfEmployee;
private int employeeId;
private String nameOfDesignation;
private D dateOfJoining;
public Employee() {
this.nameOfEmployee = "";
this.employeeId = 2000;
this.nameOfDesignation = "Intern";
this.dateOfJoining = new D();
this.dateOfJoining.setDate(01, 01, 1995);
}
public Employee(String nameOfEmployee, int employeeId, String nameOfDesignation, int dd, int mm, int yyyy) {
this.nameOfEmployee = nameOfEmployee;
this.employeeId = employeeId;
this.nameOfDesignation = nameOfDesignation;
this.dateOfJoining = new D();
this.dateOfJoining.setDate(dd, mm, yyyy);
}
public void setNameOfEmployee(String nameOfEmployee) {
this.nameOfEmployee = nameOfEmployee;
}
public String getNameOfEmployee() {
return this.nameOfEmployee;
}
public void setEmployeeId(int employeeId) {
this.employeeId = employeeId;
}
public int getEmployeeId() {
return employeeId;
}
public void setNameOfDesignation(String nameOfDesignation) {
this.nameOfDesignation = nameOfDesignation;
}
public String getNameOfDesignation() {
return nameOfDesignation;
}
public void setDateOfJoining(int dd, int mm, int yyyy) {
this.dateOfJoining.setDate(dd, mm, yyyy);
}
public String getDateOfJoining() {
String dateOfJoining = this.dateOfJoining.getDate();
return dateOfJoining;
}
public void printEmployeeInformation() {
System.out.print("Name of Employee: ");
System.out.println(this.getNameOfEmployee());
System.out.print("Employee ID: ");
System.out.println(this.getEmployeeId());
System.out.print("Designation: ");
System.out.println(this.getNameOfDesignation());
System.out.print("Date of Joining: ");
System.out.println(this.getDateOfJoining());
}
}
public class Demo {
public static void main(String[] args) {
Student s1 = new Student("Ayush", 2001, "Intern", 05, 05, 2002);
Employee e1 = new Employee("Ayush", 2001, "Intern", 05, 05, 2023);
s1.printStudentInformation();
e1.printEmployeeInformation();
}
}