Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

public class Classroom { // Constants. You can refer to these anywhere within the Classroom class. private static final int CLASS_CAPACITY 15; private static final

image text in transcribedimage text in transcribed

public class Classroom { // Constants. You can refer to these anywhere within the Classroom class. private static final int CLASS_CAPACITY 15; private static final int WAIT_LIST_CAPACITY = 5; // Instance variables. private HashMap registeredStudents; private HashSet enrolledIds; private Queue waitlistIds; public Classroom() { // TODO: Implement. Initialize any instance variables here. } public void register Student (Student student) { // TODO: Implement. The student should be registered, but not enrolled in the class or added to the waitlist. } public void enrollStudent(int id) { // TODO: Implement. The student with the provided ID should be added the enrolled students set if there is // capacity. If there is not, but there is capacity in the waitlist, the student should be added to that // instead. If there is no capacity in the enrollment set or the waitlist, the request can be ignored. } public void dropStudent(int id) { // TODO: Implement. Attempt to remove the student with the provided ID from the enrolled students set. If the // student was removed, backfill the enrolled students set with a student from the waitlist. } public ArrayList getEnrolledStudents() { // TODO: Implement. Return the names of all students that are enrolled in an ArrayList. return new ArrayList(); } public ArrayList getWaitlistedStudents() { // TODO: Implement. Return the names of all of the students that are in the waitlist in an ArrayList. // They should be in the same order that they are in the waitlist. return new ArrayList(); } public static void main(String[] args) { Classroom classroom = new Classroom(); if (NAMES.Length != IDS.Length) { throw new RuntimeException("Oops! The NAMES and IDS arrays don't match. Did they get modified?"); } // Register all of the students defined by NAMES and IDS below. for (int i = 0; i registeredStudents; private HashSet enrolledIds; private Queue waitlistIds; public Classroom() { // TODO: Implement. Initialize any instance variables here. } public void register Student (Student student) { // TODO: Implement. The student should be registered, but not enrolled in the class or added to the waitlist. } public void enrollStudent(int id) { // TODO: Implement. The student with the provided ID should be added the enrolled students set if there is // capacity. If there is not, but there is capacity in the waitlist, the student should be added to that // instead. If there is no capacity in the enrollment set or the waitlist, the request can be ignored. } public void dropStudent(int id) { // TODO: Implement. Attempt to remove the student with the provided ID from the enrolled students set. If the // student was removed, backfill the enrolled students set with a student from the waitlist. } public ArrayList getEnrolledStudents() { // TODO: Implement. Return the names of all students that are enrolled in an ArrayList. return new ArrayList(); } public ArrayList getWaitlistedStudents() { // TODO: Implement. Return the names of all of the students that are in the waitlist in an ArrayList. // They should be in the same order that they are in the waitlist. return new ArrayList(); } public static void main(String[] args) { Classroom classroom = new Classroom(); if (NAMES.Length != IDS.Length) { throw new RuntimeException("Oops! The NAMES and IDS arrays don't match. Did they get modified?"); } // Register all of the students defined by NAMES and IDS below. for (int i = 0; i

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

Oracle Database 19c DBA By Examples Installation And Administration

Authors: Ravinder Gupta

1st Edition

B09FC7TQJ6, 979-8469226970

More Books

Students also viewed these Databases questions