CS430 Lab 9Giving the following Employee class that models general employees of a company: import java.util.Calendar; import java.util.GregorianCalendar; public class Employee implements
Trang 1CS430 Lab 9
Giving the following Employee class that models general employees of a company:
import java.util.Calendar;
import java.util.GregorianCalendar;
public class Employee implements Comparable<Employee> {
private int employeeId;
private String firstName;
private String lastName;
private GregorianCalendar birthday;
public Employee(int id, String fn, String ln, GregorianCalendar bday) {
employeeId = id; firstName = fn; lastName = ln; birthday = bday; }
public int getEmployeeId() {
return employeeId;
}
public String getFirstName() {
return firstName;
}
public String getLastName() {
return lastName;
}
public GregorianCalendar getBirthday() {
return birthday;
}
public String toString() {
String str = String.format("Employee %s %s: id %d, birthday %d/%d/%d",
getFirstName(), getLastName(), getEmployeeId(), getBirthday().get(Calendar.MONTH), getBirthday().get(Calendar.DATE), getBirthday().get(Calendar.YEAR));
return str; }
@Override
public int compareTo(Employee o) {
// add code to order the employee by last name
}
}
(ArrayList) Create an EmployeeTest class to test the Employee class Create an ArrayList and 3 Employee objects Add the 3 Employee objects to the ArrayList Create the forth Employee object and add it to the ArrayList at position 1 Print the ArrayList unordered, as well as ordered by last name and birthday.
(LinkedList) Create an EmployeeTest class to test the Employee class Create a LinkedList and 3 Employee objects Add the 3 Employee objects to the LinkedList Create the forth Employee object
Trang 2and add it to the beginning of the LinkedList Print the LinkedList unordered, as well as ordered by last name and birthday.