Question
You've been tasked with overhauling QUT's 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 QUT's 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 Map is used here to represent the key-value pairings between units and students (thus constituting enrollments). Here, our Map keys are of type String and our values are of type Set
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.
Notice how we use HashMap on the right-hand side of this line, but Map on the left-hand side. This is because Map is the interface, and HashMap is one of several concrete implementation of Map (like List versus ArrayList in the previous exercise).
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 Map values.
Again, you should read up on the methods and properties JDK APIs for the relevant collections in this exercise, as they will handle a lot of the work for you.
Finally, upload and submit your 1 class:
EnrollmentManager
ENROLLMENTMANAGER.JAVA FILE BELOW
package coll.EnrollmentManager;
import java.util.*;
public class EnrollmentManager {
private static 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
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
return null;
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started