Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You've been tasked with overhauling an enrollment management system. Complete the EnrollementManager class. All methods and fields should be static because EnrollmentManager does not need

You've been tasked with overhauling an enrollment management system. Complete the EnrollementManager class. All methods and fields should be static because EnrollmentManager does not need to be instantiated as an object.

Consider the first line of the class:

private static HashMap> enrollments = new HashMap>();

A HashMap (which is a subclass of Map) is used here to represent the key-value pairings between units and students (thus constituting enrollments). Here, our HashMap keys are of type String and our values are of type Set. Therefore, we can lookup a collection of students (the value) corresponding to a particular unit (the key).

A Set is used here to represent collections of students because it has the special property of enforcing unique students (no duplicate elements) for each unit.

Although Set is also an interface, we do not need to specify one of the several Set implementations here because, at this point, we are only specifying the type arguments of our HashMap object. These type arguments only specify the type of the elements contained within the collection (and not the actual object values). Thus, it is up to you which of the Set implementations you use when it comes to instantiating objects to be stored in the HashMap values.

package coll.EnrollmentManager;

import java.util.*;

public class EnrollmentManager {

private static HashMap> enrollments = new HashMap>();

/**

* Enrolls a student into a unit.

*

* @param unit

* @param student

*/

public static void enroll(String unit, String student) {

}

/**

* Gets the HashMap containing the current enrollments.

*

* @return

*/

public static HashMap> getEnrollments() {

return null;

}

/**

* Removes all enrollments form the HashMap.

*/

public static void wipeEnrollments() {

}

/**

* Withdraws a student from a unit.

*

* @param unit

* @param student

*/

public static void withdrawEnrollment(String unit, String student) {

}

/**

* Withdraws a student from all units they are enrolled in.

*

* @param student

*/

public static void withdrawStudent(String student) {

}

/**

* Gets a list of all students of a particular discipline. E.g. If discipline is

* "ABC" then return a collection of all students enrolled in units that start

* with "ABC", so ABC301, ABC299, ABC741 etc. This method is non-trivial so it

* would help to first implement the helper method matchesDiscipline (below).

*

* @param discipline

* @return

*/

public static Set getStudents(String discipline) {

return null;

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

8th Edition

013460153X, 978-0134601533

More Books

Students also viewed these Databases questions