Приложение 7. Пример кода классов Employee и Manager



 

public class Manager extends Employee {

private Employee secretary;

public Manager (String n, double s, int year, int month, int day) {

super (n, s, year, month, day);

secretary = null;

}

public void setSecretary (Employee s) {

secretary = s;

}

}

public class Employee implements Serializable {

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;

}

public void raiseSalary (double byPercent) {

double raise=salary*byPercent/100;

salary+=raise;

}

}


Дата добавления: 2019-07-15; просмотров: 153; Мы поможем в написании вашей работы!

Поделиться с друзьями:






Мы поможем в написании ваших работ!