I need some help with Merge Sort. I understand how it works, just having some pr
ID: 3641544 • Letter: I
Question
I need some help with Merge Sort. I understand how it works, just having some problems implementing it. I have 2 classes and a driver. My first class is called Person and has the appropriate get set methods for personID, personName, and personAge. The second class is called employee and contains testdata for the array which is to be used. I need to assemble the testdata into an array of employees, and return it it to the driver, then call on MergeSort() without any arguments and sort the array and pass that result back to the driver. The employees need to be sorted by personID.Here are the employee class and driver. (I can't change the driver as it was provided to use as-is)
*** Person Class ***
public class Person
{
private int personID;
private String personName;
private int personAge;
public Person()
{
}
public Person( int id, String name, int age )
{
personID = id;
personName = name;
personAge = age;
}
public void setpersonID ( int id )
{
personID = id;
}
public int getpersonID ()
{
return personID;
}
public void setpersonName ( String name )
{
personName = name;
}
public String getpersonName ()
{
return personName;
}
public void setpersonAge ( int age )
{
personAge = age;
}
public int getpersonAge ()
{
return personAge;
}
public String toString()
{
return "EmployeeID: " + personID + " Employee Name: " + personName + " Employee Age: " + personAge;
}
} // End Class Person
***Employee Class***
public class employee
{
private Person Employees[];
public employee()
{
}
public employee(int number)
{
Employees = new Person[number];
}
public Person[] MergeSort()
{
// this is where I need help
}
public void CreateTestData()
{
Employees[0] = new Person(39, "Mark", 19);
Employees[1] = new Person(67, "Kevin", 39);
Employees[2] = new Person(25, "Frank", 47);
Employees[3] = new Person(93, "Maria", 56);
Employees[4] = new Person(31, "Evan", 29);
Employees[5] = new Person(18, "Audrey", 72);
Employees[6] = new Person(46, "Debbie", 65);
Employees[7] = new Person(84, "Ruth", 19);
Employees[8] = new Person(62, "Kathy", 71);
Employees[9] = new Person(10, "Mona", 45);
}
public String toString()
{
for(int l=0; l < Employees.length ; l++)
System.out.println(Employees[l].toString());
return "";
} // end method toString
}
*** Driver ***
import java.util.Scanner;
public class Driver
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
employees myEmployees = new employee(10);
myEmployees.CreateTestData();
System.out.println(myEmployees.toString() + " ");
myEmployees.MergeSort();
System.out.println(myEmployees.toString() + " ");
}
}