This class captures information for a student at a college. It stores the name, the year
enrolled and the major of studies.
Define the equals method below so it returns true if two students have the same name. The comparison is CASE SENSITIVE (i.e., “a” is NOT equal to “A”).
*/
Student.java
public class Student
// Declaration of instance variables
private String name;
private String major;
private it yearEnrolled:
// Constructor
public Student (String n, int y) {
name = n;
major = “undeclared”;
yearEnrolled = y;
}
public void setMajor (String m) { major = m; }
public String getMajor() { return major; }
public int getYear () { return yearEnrolled; }
public String getName() { return name; }
// Define the equals method shown below
public boolean equals (Student s) {
}
public static void main(String args[])
{
Student one = new Student (“Pete”, 2020);
System.out.println(one.equals (new Student (“Pete”, 2015))) ; System.out.println(one.equals (new Student ( “Pete”, 2010))) ;
System.out.println(one.equals (new Student (“Pete”, 2020))) ;
}
}