Following is the Student class in JAVA. You are required to create StudentMatch class to inherit the Student class. You must override the following methods:
hasGreaterAge: returns true if calling object has greater age value then passed object.
hasGreaterCGPA: returns true if calling object has greater cgpa value then passed object.
hasEqualName: returns true if calling object has exactly equal name then passed object.
hasEqualAge: returns true if calling object has equal age then passed object.
hasEqualCGPA: returns true if calling object has equal cgpa then passed object.
publicclass
Student {
protected
String name;
protectedintage;
protecteddoublecgpa;
public
Student() {
name = "NULL";
age = 0;
cgpa = 0.0;
}
public
Student(String name,
intage,
doublecgpa)
{
this.name = name;
this.age = age;
this.cgpa = cgpa;
}
public
Student (Student student)
{
this(student.name,student.age,student.cgpa);
}
publicvoid
set(String name,intage,
doublecgpa)
{
this.set(name);
this.set(age);
this.set(cgpa);
}
public
Student getCopy()
{
Student student =
new
Student(this);
returnstudent;
}
public
Student getClone()
{
returnthis;
}
publicboolean
hasGreaterAge(Student student)
{
return false;
}
publicboolean
hasGreaterCgpa(Student student)
{
returnfalse;
}
publicboolean
hasEqualName(Student student)
{
returnfalse;
}
publicboolean
hasEqualAge(Student student)
{
returnfalse;
}
publicboolean
hasEqualCGPA(Student student)
{
returnfalse;
}
publicvoid
display()
{
System.
out
.println("Name : "+
this.name + ", Age : "+
this.age + ", CGPA : "+
this.cgpa);
}
publicString toString() {
String outputString =
this.name+","+this.age+","+this.cgpa+"\n";//"Ali,28,3.21\n"
returnoutputString;
}
}