parent
7b631ed852
commit
863a001f64
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
Binary file not shown.
@ -0,0 +1,66 @@
|
||||
package base;
|
||||
|
||||
public abstract class Scientist {
|
||||
protected double salary;
|
||||
protected int seniority;
|
||||
|
||||
public Scientist(double salary, int seniority) {
|
||||
this.salary = salary;
|
||||
this.seniority = seniority;
|
||||
}
|
||||
|
||||
public double getSalary() {
|
||||
return salary;
|
||||
}
|
||||
|
||||
public void setSalary(double salary) {
|
||||
this.salary = salary;
|
||||
}
|
||||
|
||||
public int getSeniority() {
|
||||
return seniority;
|
||||
}
|
||||
|
||||
public void setSeniority(int seniority) {
|
||||
this.seniority = seniority;
|
||||
}
|
||||
|
||||
// Абстрактный метод вычисления надбавки
|
||||
public abstract double computeBonus();
|
||||
|
||||
// Дополнительные методы
|
||||
public void hire() {
|
||||
System.out.println("Научный сотрудник принят на работу.");
|
||||
}
|
||||
|
||||
public void fire() {
|
||||
System.out.println("Научный сотрудник уволен.");
|
||||
}
|
||||
|
||||
public void transfer() {
|
||||
System.out.println("Научный сотрудник перемещён на новую должность.");
|
||||
}
|
||||
|
||||
public void accrueSalary() {
|
||||
double bonus = computeBonus();
|
||||
double totalSalary = salary + bonus;
|
||||
System.out.println("Начислена зарплата: " + totalSalary +
|
||||
" (ставка: " + salary + ", надбавка: " + bonus + ")");
|
||||
}
|
||||
|
||||
// Переопределение equals() и hashCode() для проверки уникальности
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
Scientist scientist = (Scientist) o;
|
||||
return Double.compare(scientist.salary, salary) == 0 &&
|
||||
seniority == scientist.seniority;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return java.util.Objects.hash(getClass(), salary, seniority);
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package engineer;
|
||||
|
||||
import base.Scientist;
|
||||
|
||||
public class Engineer extends Scientist {
|
||||
|
||||
public Engineer(double salary, int seniority) {
|
||||
super(salary, seniority);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double computeBonus() {
|
||||
double x = 0.01;
|
||||
return salary * seniority * x;
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package junior;
|
||||
|
||||
import base.Scientist;
|
||||
|
||||
public class JuniorScientist extends Scientist {
|
||||
|
||||
public JuniorScientist(double salary, int seniority) {
|
||||
super(salary, seniority);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double computeBonus() {
|
||||
double x = 0.02;
|
||||
return salary * seniority * x;
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package senior;
|
||||
|
||||
import base.Scientist;
|
||||
|
||||
public class SeniorScientist extends Scientist {
|
||||
|
||||
public SeniorScientist(double salary, int seniority) {
|
||||
super(salary, seniority);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double computeBonus() {
|
||||
double x = 0.03;
|
||||
return salary * seniority * x;
|
||||
}
|
||||
}
|
Loading…
Reference in new issue