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:

  1. Override the equals and hashCode methods in the Student class. Two students should be considered equal if their IDs are equal.

  2. 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 the Student object with the given ID if it exists in the system. Otherwise, it should return null.

    • deleteStudent(String id): This should delete the Student with the given ID from the system.

Use a HashSet<Student> to store the students in the StudentManagement class.

  1. In a Main class, demonstrate the use of the StudentManagement system by adding some students, finding a student, and deleting a student. Show that the system does not allow duplicate students based on the equals and hashCode 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:

  1. Java class files

  2. Screenshot of the Console with the code executing

 

COSC-1437 / ITSE-2457 Computer Science Dept. - Author: Dr. Kevin Roark