Project 1:
Create a class called Student that implements a compareTo method.
Students will have three fields: First Name, Last Name, and Period
The class should compare this student to another by comparing their period number; if they are equal it should compare their last names; if they are equal it should compare their first names
Copy the following tester class:
import java.util.ArrayList;
public class StudentTester
{
public static void main(String[] args)
{
ArrayList<Student> students = new ArrayList<Student>();
students.add(new Student("Jeff", "Adams", 1));
students.add(new Student("Jill", "Henderson", 3));
students.add(new Student("Craig", "Taylor", 5));
students.add(new Student("Joe", "Thomas", 1));
students.add(new Student("Betsy", "Durrence", 1));
students.add(new Student("Dina", "Jenkins", 5));
students.add(new Student("Thomas", "Clowney", 1));
students.add(new Student("Tracey", "Martin", 1));
students.add(new Student("Ted", "Sapp", 5));
students.add(new Student("Brianna", "Sapp", 5));
students.add(new Student("David", "Medrano", 3));
students.add(new Student("Brianna", "Brunson", 5));
students.add(new Student("Peter", "Keevey", 1));
students.add(new Student("Jan", "Martin", 1));
}
}
· Create an array (not ArrayList) called students2. Copy all the student from the students ArrayList in to the students2 array.
· Create a student Student a = new Student(“Joe”, “Thomas”, 1);
· Create a method in the tester class called sequentialSearch.
· Call the method sequentialSearch to search the students ArrayList for Student a. It should return and print 3.
· Create a method in the tester class called selectionSort
· Sort the students in the students ArrayList.
· Print out the sorted students ArrayList to see that they are first sorted by period and then by last name and then by first name
· Create a method in the tester class called binarySearch.
· Call the method binarySearch to search the students ArrayList for Jill Henderson from 3rd period.
· Create a method in the tester class called insertionSort
· Sort the students in the students2 array.
· Print out the sorted students2 array to see that they are first sorted by period and then by last name and then by first name
- Draw a diagram with written explanation for how merge sort would sort the original ArrayList.