-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestEmployeeObject.java
50 lines (43 loc) · 1.06 KB
/
TestEmployeeObject.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
import java.util.Scanner;
class Employee
{
String name;
int e_id;
float salary;
boolean status;
Scanner sc = new Scanner(System.in);
void setData()
{
System.out.println("Enter Name (String) of Employee: " );
name=sc.nextLine();
System.out.println("Enter Employee ID (Integer) of Employee: " );
e_id=sc.nextInt();
System.out.println("Enter Salary (Float) of Employee: " );
salary=sc.nextFloat();
System.out.println("Enter Working Satus (Boolean) of Employee: " );
status=sc.nextBoolean();
}
void getData()
{
System.out.println("Name:"+name+"\nEmp Id:"+e_id+"\nSalary:"+salary+"\nStatus:"+status);
}
Employee copyEmployee(Employee e) //Mehod with objects
{
Employee de = e;
return de;
}
}
/*** Main Class***/
class TestEmployeeObject
{
public static void main(String args[])
{
Employee e = new Employee();
e.setData();
System.out.println("\n\n Details of Employee : "+e.name );
e.getData();
Employee ecopy = e.copyEmployee(e);
System.out.println("\n\n Details of copy of Employee : "+e.name );
ecopy.getData();
}
}