Extend the Student class below by implementing a new accessor getStudentKey(). This routine returns a key for each student that combines the year of admission, the major, and the first 3 letters of the student’s name. For example, for a student with name Rose, admitted in 2020 and majoring in accounting, the key should be 2020AccountingRos.
There is a special case if the name of the student is less than three characters long (e.g., Jo), then just use the full name (i.e., Jo).
Student Class:
public class Student
{
// Declaration of instance variables
private String name;
private String major;
private int 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; }
public String getStudentKey() {
// your code here
}
}
What I have so far:
public String getStudentKey()
{
}