Module 3 - Student Management System
Objective
Create a simple Student Management System where you can add, find, and delete students based on their ID.
A Student
class starter has been provided with the following properties:
public class Student {
private String id;
private String name;
private String major;
}
Tasks:
Override the
equals
andhashCode
methods in theStudent
class. Two students should be considered equal if their IDs are equal.Create a
StudentManagement
class with the following methods:addStudent(Student student)
: This should add a student to the system. However, the system should not allow duplicate student IDs.findStudent(String id)
: This should return theStudent
object with the given ID if it exists in the system. Otherwise, it should return null.deleteStudent(String id)
: This should delete theStudent
with the given ID from the system.
Use a HashSet<Student>
to store the students in the StudentManagement
class.
In a
Main
class, demonstrate the use of theStudentManagement
system by adding some students, finding a student, and deleting a student. Show that the system does not allow duplicate students based on theequals
andhashCode
implementations.
Notes:
Remember that when you are overriding equals
and hashCode
, they should both rely on the same properties of the object. In this case, they should both only use the student's ID for their calculations/comparisons.
Deliverables
Upload the following files in a zip folder that you have created:
Java class files
Screenshot of the Console with the code executing
COSC-1437 / ITSE-2457 Computer Science Dept. - Author: Dr. Kevin Roark