Beruflich Dokumente
Kultur Dokumente
// x-x-x-x-x-x-x-x-x-x-x-x-x-xx-x-x-x-x-x-x-x-x-x-x-x-x-x
53. class PairAlg
54. {
55.
public static boolean hasNulls(Pair<?> p)
56.
{
57.
return p.getFirst() == null || p.getSecond() == null;
58.
}
59.
60.
public static void swap(Pair<?> p) { swapHelper(p); }
61.
62.
public static <T> void swapHelper(Pair<T> p)
63.
{
64.
T t = p.getFirst();
65.
p.setFirst(p.getSecond());
66.
p.setSecond(t);
67.
}
68. }
69.
// x-x-x-x-x-x-x-x-x-x-x-x-x-xx-x-x-x-x-x-x-x-x-x-x-x-x-x
70. class Employee
71. {
72.
public Employee(String n, double s, int year, int month, int day)
73.
{
74.
name = n;
75.
salary = s;
76.
GregorianCalendar calendar = new GregorianCalendar(year, month - 1, d
ay);
77.
hireDay = calendar.getTime();
78.
}
79.
80.
public String getName()
81.
{
82.
return name;
83.
}
84.
85.
public double getSalary()
86.
{
87.
return salary;
88.
}
89.
90.
public Date getHireDay()
91.
{
92.
return hireDay;
93.
}
94.
95.
public void raiseSalary(double byPercent)
96.
{
97.
double raise = salary * byPercent / 100;
98.
salary += raise;
99.
}
100.
101.
private String name;
102.
private double salary;
103.
private Date hireDay;
104. }
105.
// x-x-x-x-x-x-x-x-x-x-x-x-x-xx-x-x-x-x-x-x-x-x-x-x-x-x-x
106. class Manager extends Employee
107. {
108.
/**
109.
@param n the employee's name
110.
@param s the salary
111.
@param year the hire year
112.
@param month the hire month
113.
@param day the hire day
114. */
115. public Manager(String n, double s, int year, int month, int day)
116. {
117.
super(n, s, year, month, day);
118.
bonus = 0;
119. }
120.
121. public double getSalary()
122. {
123.
double baseSalary = super.getSalary();
124.
return baseSalary + bonus;
125. }
126.
127. public void setBonus(double b)
128. {
129.
bonus = b;
130. }
131.
132. public double getBonus()
133. {
134.
return bonus;
135. }
136.
137. private double bonus;
138. }