Supply compatible hashCode and equals methods to the Student class described in Exercise P16.8. Test the hash code by adding Student objects to a hash set.

Complete the following file:

Student.java

Use the following file:

StudentTester.java

import java.util.Set;
import java.util.Iterator;
import java.util.HashSet;

/**
   A program to test hash codes of students.
*/
public class StudentTester
{
   public static void main(String[] args)
   {
      Student s1 = new Student("Carl", "Wong", 1723);
      Student s2 = new Student("Joe", "Wong", 1524);
      Student s3 = new Student("Joe", "Wong", 1699);
      Student s4 = new Student("Carl", "Wong", 1723);
      
      System.out.println(s2.equals(s3));
      System.out.println("Expected: false");
      System.out.println(s1.equals(s4));
      System.out.println("Expected: true");

      Set<Student> students = new HashSet<Student>();
      students.add(s1);
      students.add(s2);
      students.add(s3);
      students.add(s4);

      System.out.println("Size: " + students.size());
      System.out.println("Expected: 3");
   }
}