58 lines
1.1 KiB
Java
58 lines
1.1 KiB
Java
package randomAccess2;
|
|
|
|
import java.util.*;
|
|
|
|
public class Employee
|
|
{
|
|
public static final int NAME_SIZE = 40;
|
|
public static final int RECORD_SIZE = 2 * NAME_SIZE + 8 + 4 + 4 + 4;
|
|
|
|
private String name;
|
|
private double salary;
|
|
private Date hireDay;
|
|
|
|
public Employee() {}
|
|
|
|
public Employee(String n, double s, int year, int month, int day)
|
|
{
|
|
name = n;
|
|
salary = s;
|
|
GregorianCalendar calendar = new GregorianCalendar(year, month - 1, day);
|
|
hireDay = calendar.getTime();
|
|
}
|
|
|
|
public String getName()
|
|
{
|
|
return name;
|
|
}
|
|
|
|
public double getSalary()
|
|
{
|
|
return salary;
|
|
}
|
|
|
|
public Date getHireDay()
|
|
{
|
|
return hireDay;
|
|
}
|
|
|
|
/**
|
|
Raises the salary of this employee.
|
|
@byPercent the percentage of the raise
|
|
*/
|
|
public void raiseSalary(double byPercent)
|
|
{
|
|
double raise = salary * byPercent / 100;
|
|
salary += raise;
|
|
}
|
|
|
|
public String toString()
|
|
{
|
|
return getClass().getName()
|
|
+ "[name=" + name
|
|
+ ",salary=" + salary
|
|
+ ",hireDay=" + hireDay
|
|
+ "]";
|
|
}
|
|
}
|