In my Main
class I have this piece of code:
UUID uniqueID;
public void createEmployee(){
uniqueID = UUID.randomUUID();
// ...
}
In my class Corporation
there's a method called promoteEmployee
, which should receive the uniqueID as parameter. Is that possible, and when yes, how?
public void promoteEmployee(uniqueID){
// it doesn't recognize uniqueID as argument
}
I also have the method sortEmployees
, which sorts the ArrayList alphabetically, and if two names are equal, the employee with a higher salary should be printed out first. It sorts the List alphabetically, but doesn't check if the salary is bigger. What do I need to change?
ArrayList<Employee> employees = new ArrayList<Employee>();
public void sortEmployees(){
Collections.sort(employees, (p1, p2) -> p1.name.compareTo(p2.name));
for(Employee employee: employees){
Comparator.comparing(object -> employee.name).thenComparingDouble(object -> employee.grossSalary);
System.out.println("ID: " + employee.ID + END_OF_LINE + "Name: "+employee.name + END_OF_LINE + "Salary: " + employee.grossSalary);
System.out.println(""); // just an empty line
}
}