Modify Employee & add HR & Accountant classes.
This commit is contained in:
parent
83b541d890
commit
ed6fbf9916
@ -5,13 +5,12 @@
|
|||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="ddee1498-b134-461c-9aaa-55fbcffaf4ea" name="Changes" comment="">
|
<list default="true" id="ddee1498-b134-461c-9aaa-55fbcffaf4ea" name="Changes" comment="">
|
||||||
<change afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
<change afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/Main.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Main.java" afterDir="false" />
|
||||||
<change afterPath="$PROJECT_DIR$/.idea/modules.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/com/school/manager/people/Human.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/com/school/manager/people/Human.java" afterDir="false" />
|
||||||
<change afterPath="$PROJECT_DIR$/.idea/vcs.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/com/school/manager/people/employees/Employee.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/com/school/manager/people/employees/Employee.java" afterDir="false" />
|
||||||
<change afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/com/school/manager/people/employees/Experience.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/com/school/manager/people/employees/Experience.java" afterDir="false" />
|
||||||
<change afterPath="$PROJECT_DIR$/school-manager.iml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/com/school/manager/people/employees/Position.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/com/school/manager/people/employees/Position.java" afterDir="false" />
|
||||||
<change afterPath="$PROJECT_DIR$/src/Main.java" afterDir="false" />
|
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
|
@ -4,10 +4,22 @@ import com.school.manager.people.employees.Position;
|
|||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
Human human = new Human("Stan", "Jarocki", "123456789", 2002, 11, 6);
|
|
||||||
|
|
||||||
Employee owner = new Employee(human, "Manager", 5000);
|
Human personOne = new Human("Mike", "Vezovski", "123456789", 2002, 11, 6);
|
||||||
|
Human personTwo = new Human("John", "Doe", "220002323", 1992, 11, 6);
|
||||||
|
Human personThree = new Human("Johnny", "Smith", "123453289", 2004, 11, 6);
|
||||||
|
|
||||||
owner.showInfo();
|
Employee employeeOne = new Employee(personOne, Position.MANAGER, 5000);
|
||||||
|
Employee employeeTwo = new Employee(personTwo, Position.ACCOUNTANT, 4100);
|
||||||
|
Employee employeeThree = new Employee(personThree, Position.TEACHER, 4000);
|
||||||
|
|
||||||
|
personOne.showInfo();
|
||||||
|
employeeOne.showInfo();
|
||||||
|
System.out.println("----------------------");
|
||||||
|
personTwo.showInfo();
|
||||||
|
employeeTwo.showInfo();
|
||||||
|
System.out.println("----------------------");
|
||||||
|
personThree.showInfo();
|
||||||
|
employeeThree.showInfo();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -31,6 +31,8 @@ public class Human {
|
|||||||
this.surname = surname;
|
this.surname = surname;
|
||||||
this.pesel = pesel;
|
this.pesel = pesel;
|
||||||
this.birthDate = LocalDate.of(birthYear, birthMonth, birthDay);
|
this.birthDate = LocalDate.of(birthYear, birthMonth, birthDay);
|
||||||
|
|
||||||
|
this.updateAge();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
@ -42,9 +44,9 @@ public class Human {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void showInfo() {
|
public void showInfo() {
|
||||||
System.out.println("Imię: " + getName());
|
System.out.println("Name: " + getName());
|
||||||
System.out.println("Nazwisko: " + getSurname());
|
System.out.println("Surname: " + getSurname());
|
||||||
System.out.println("Wiek: " + getAge());
|
System.out.println("Age: " + getAge());
|
||||||
System.out.println("PESEL: " + getPesel());
|
System.out.println("PESEL: " + getPesel());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,7 +54,7 @@ public class Human {
|
|||||||
LocalDate currentDate = LocalDate.now();
|
LocalDate currentDate = LocalDate.now();
|
||||||
Period dateDifference = Period.between(birthDate, currentDate);
|
Period dateDifference = Period.between(birthDate, currentDate);
|
||||||
int currentAge = dateDifference.getYears();
|
int currentAge = dateDifference.getYears();
|
||||||
this.setAge(age);
|
this.setAge(currentAge);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean checkHasBirthdayToday() {
|
public boolean checkHasBirthdayToday() {
|
||||||
|
@ -7,18 +7,18 @@ import java.util.List;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
public class Employee extends Human {
|
public class Employee extends Human {
|
||||||
private List<String> positions = new ArrayList<String>();
|
private List<Position> positions = new ArrayList<Position>();
|
||||||
private int salary;
|
private int salary;
|
||||||
|
|
||||||
public List<String> getPositions() {
|
public List<Position> getPositions() {
|
||||||
return positions;
|
return positions;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPosition(String newPosition) {
|
public void addPosition(Position newPosition) {
|
||||||
this.positions.add(newPosition);
|
this.positions.add(newPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Employee(Human human, String position, int salary) {
|
public Employee(Human human, Position position, int salary) {
|
||||||
super(human.getName(), human.getSurname(), human.getPesel(), human.getBirthDate().getYear(), human.getBirthDate().getMonthValue(), human.getBirthDate().getDayOfMonth());
|
super(human.getName(), human.getSurname(), human.getPesel(), human.getBirthDate().getYear(), human.getBirthDate().getMonthValue(), human.getBirthDate().getDayOfMonth());
|
||||||
this.positions.add(position);
|
this.positions.add(position);
|
||||||
this.salary = salary;
|
this.salary = salary;
|
||||||
@ -29,11 +29,11 @@ public class Employee extends Human {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void fire() {
|
public void fire() {
|
||||||
List<String> positions = this.getPositions();
|
List<Position> positions = this.getPositions();
|
||||||
Iterator<String> iter = positions.iterator();
|
Iterator<Position> iter = positions.iterator();
|
||||||
|
|
||||||
while(iter.hasNext()) {
|
while(iter.hasNext()) {
|
||||||
String position = iter.next();
|
Position position = iter.next();
|
||||||
iter.remove();
|
iter.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -47,19 +47,19 @@ public class Employee extends Human {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void showInfo() {
|
public void showInfo() {
|
||||||
List<String> positions = this.getPositions();
|
List<Position> positions = this.getPositions();
|
||||||
|
|
||||||
if (positions.size() == 0) {
|
if (positions.size() == 0) {
|
||||||
System.out.println("Brak Stanowiska");
|
System.out.println("No position");
|
||||||
} else if (positions.size() == 1) {
|
} else if (positions.size() == 1) {
|
||||||
System.out.println("Stanowisko: " + positions.get(0));
|
System.out.println("Position: " + positions.get(0).capitalize());
|
||||||
} else {
|
} else {
|
||||||
System.out.println("Stanowiska: ");
|
System.out.println("Positions: ");
|
||||||
for (String position : positions) {
|
for (Position position : positions) {
|
||||||
System.out.println(" - " + position);
|
System.out.println(" - " + position.capitalize());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
System.out.println("Płaca: " + getSalary());
|
System.out.println("Salary: " + getSalary());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,6 @@ package com.school.manager.people.employees;
|
|||||||
|
|
||||||
public enum Experience {
|
public enum Experience {
|
||||||
JUNIOR,
|
JUNIOR,
|
||||||
|
REGULAR,
|
||||||
|
SENIOR
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
package com.school.manager.people.employees.HumanResourcesEmployee;
|
||||||
|
|
||||||
|
public class Accountant {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,37 @@
|
|||||||
|
package com.school.manager.people.employees.HumanResourcesEmployee;
|
||||||
|
|
||||||
|
import com.school.manager.people.Human;
|
||||||
|
import com.school.manager.people.employees.Employee;
|
||||||
|
import com.school.manager.people.employees.Position;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class HumanResourcesEmployee extends Employee {
|
||||||
|
public Boolean getHasAccessToCompanyVault() {
|
||||||
|
return hasAccessToCompanyVault;
|
||||||
|
}
|
||||||
|
|
||||||
|
Boolean hasAccessToCompanyVault;
|
||||||
|
|
||||||
|
public Boolean getHasAccessToSensitiveEmployeesData() {
|
||||||
|
return hasAccessToSensitiveEmployeesData;
|
||||||
|
}
|
||||||
|
|
||||||
|
Boolean hasAccessToSensitiveEmployeesData;
|
||||||
|
|
||||||
|
List<SocialMedia> activeOnSocialMediaAccounts;
|
||||||
|
|
||||||
|
public HumanResourcesEmployee(Human human, Position position, int salary, Boolean hasAccessToCompanyVault) {
|
||||||
|
super(human, position, salary);
|
||||||
|
this.hasAccessToSensitiveEmployeesData = hasAccessToCompanyVault;
|
||||||
|
this.hasAccessToCompanyVault = hasAccessToCompanyVault;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void openVault() {
|
||||||
|
if(this.getHasAccessToCompanyVault()) {
|
||||||
|
System.out.println("Vault has been opened!");
|
||||||
|
} else {
|
||||||
|
System.out.println("This employee doesn't have access to the vault!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
package com.school.manager.people.employees.HumanResourcesEmployee;
|
||||||
|
|
||||||
|
public enum SocialMedia {
|
||||||
|
FACEBOOK,
|
||||||
|
INSTAGRAM,
|
||||||
|
TIKTOK
|
||||||
|
}
|
@ -2,12 +2,12 @@ package com.school.manager.people.employees;
|
|||||||
|
|
||||||
public enum Position {
|
public enum Position {
|
||||||
MANAGER,
|
MANAGER,
|
||||||
SUPERVISOR,
|
TECHNICIAN,
|
||||||
ENGINEER,
|
TEACHER,
|
||||||
ANALYST,
|
ACCOUNTANT;
|
||||||
CLERK;
|
|
||||||
|
|
||||||
public String capitalize() {
|
public String capitalize() {
|
||||||
return this.name().toLowerCase();
|
String name = this.name();
|
||||||
};
|
return name.substring(0, 1) + name.substring(1).toLowerCase();
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user