-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconstructor_Employee.java
More file actions
66 lines (56 loc) · 2.04 KB
/
Copy pathconstructor_Employee.java
File metadata and controls
66 lines (56 loc) · 2.04 KB
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
package oop.basic;
import java.util.Scanner;
public class constructor_Employee {
private int id;
private String name,gender,position,dob;
private float salary;
// defaul
public constructor_Employee(){
id = 12034;
name = "Jing Kang";
gender = "Male";
position = "Team Leader";
dob = "10/04/1993";
salary = 2000;
}
// construtor with parameter
public constructor_Employee(int id, String name, String gender, String position, String dob, float salary){
this.id = id;
this.name = name;
this.gender = gender;
this.position = position;
this.dob = dob;
this.salary = salary;
}
// Input
public void Input(){
Scanner objin = new Scanner(System.in);
System.out.print("Input ID :"); id = objin.nextInt();
System.out.print("Input Name :"); name = objin.next();
System.out.print("Input gender :"); gender = objin.next();
System.out.print("Input position :"); position = objin.next();
System.out.print("Input dob :"); dob = objin.nextLine();
System.out.print("Input salary :"); salary = objin.nextFloat();
}
// Output
public void Output(){
System.out.println(" ID :"+id);
System.out.println(" Name :"+name);
System.out.println(" Gender :"+gender);
System.out.println(" Position :"+position);
System.out.println(" dob :"+dob);
System.out.println(" Salary :"+salary+"$");
}
public static void main(String[] args) {
// defual constructor
constructor_Employee cm = new constructor_Employee();
cm.Output();
// constructer with paramater
constructor_Employee cm1 = new constructor_Employee(2001,"SereyPanha","Male","Manager","10/03/2002",2000);
cm1.Output();
// Input Output
constructor_Employee cm2 = new constructor_Employee();
cm2.Input();
cm2.Output();
}
}