-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathholdon.java
More file actions
95 lines (71 loc) · 1.28 KB
/
holdon.java
File metadata and controls
95 lines (71 loc) · 1.28 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
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
import java.util.Random;
public class holdon
{
public static void main(String[] args)
{
EmInfor[] staff = new EmInfor[3];
staff[0] = new EmInfor("Tom",23134);
staff[1] = new EmInfor(66666);
staff[2] = new EmInfor();
for(EmInfor e : staff)
{
e.setId();
System.out.println(e.getName()+" "+e.getSalary()+" "+e.getId());
}
}
}
class EmInfor
{
private static int nextId;
private String name = "";
private double salary;
private int id;
static
{
Random generator = new Random();
nextId = generator.nextInt(10000);
}
{
id = nextId;
nextId++;
}
public EmInfor(String n, double s)
{
name = n;
salary = s;
}
public EmInfor(double s)
{
this("EmInfor #"+nextId,s);
}
public EmInfor()
{
}
public String getName()
{
return name;
}
public double getSalary()
{
return salary;
}
public double getId()
{
return id;
}
public void setId()
{
id = nextId;
nextId++;
}
public void raiseSalary(double bypercent)
{
double raise = salary*bypercent/100;
salary += raise;
}
public static void main(String[] args)
{
EmInfor e = new EmInfor("Harry",50000);
System.out.println(e.getName()+e.getSalary());
}
}