Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"image": "mcr.microsoft.com/devcontainers/java:21"
}
5 changes: 5 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"recommendations": [
"vscjava.vscode-java-pack"
]
}
43 changes: 43 additions & 0 deletions Company.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,47 @@ public void print() {
e.print();
}
}

public class Employee {

private int employeeId;
private Person person;
private int salary;

public Employee(int employeeId, Person person, int salary) {
this.employeeId = employeeId;
this.person = person;
this.salary = salary;
}

public int getEmployeeId() {
return employeeId;
}

public String getName() {
return person.getName();
}

public int getSalary() {
return salary;
}

public void setSalary(int salary)
throws SalaryDecreaseException, SalaryIncreaseTooHighException {
if (salary < this.salary) {
throw new SalaryDecreaseException();
}

double increase = (double) (salary - this.salary) / this.salary;
if (increase > 0.1) {
throw new SalaryIncreaseTooHighException();
}

this.salary = salary;
}

public void print() {
System.out.println(employeeId + " - " + getName() + " - " + salary + " Euro");
}
}
}
41 changes: 0 additions & 41 deletions Employee.java

This file was deleted.

10 changes: 5 additions & 5 deletions Exercise.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ public static void main(String[] args) {
Person p2 = new Person("Hans Mueller");
Person p3 = new Person("Lisa Meier");

Employee e1 = new Employee(1, p1, 50000);
Employee e2 = new Employee(2, p2, 75000);
Employee e3 = new Employee(3, p3, 40000);
Company.Employee e1 = company.new Employee(1, p1, 50000);
Company.Employee e2 = company.new Employee(2, p2, 75000);
Company.Employee e3 = company.new Employee(3, p3, 40000);

company.addEmployee(e1);
company.addEmployee(e2);
company.addEmployee(e3);
company.addEmployee(new Employee(4, new Person("Peter Schneider"), 55000));
company.addEmployee(new Employee(5, new Person("Miriam Albers"), 90000));
company.addEmployee(company.new Employee(4, new Person("Peter Schneider"), 55000));
company.addEmployee(company.new Employee(5, new Person("Miriam Albers"), 90000));

try {
e1.setSalary(55000);
Expand Down
Loading