Answered step by step
Verified Expert Solution
Question
1 Approved Answer
subject: software development please help. Classroom.java package edu.csc413.collections; import java.util.*; public class Classroom { // Constants. You can refer to these anywhere within the Classroom
subject: software development
please help. Base Version You are provided with a partially implemented Classroom., and a completed file. Student.java. Your task is to implement all of the methods in Classroom.dost. You will need to provide implementation code in every section of the file where you were the following comment // TODO: Implement. The Classroom manages a roster of registered students Students can be enrolled waited or neither . When a student la registered the Classroom object should track that students Information, so that it can be retrieved later with just the student registering a student does not enroll them in the car add them to the waist When a students enrolled, they are placed in a collection tracking the IDs of students enrolled in the class. The student can only be enrolled if there is spare capacity.net there should be an attempt to place them in the wait When a student is placed in the waitlist, they go to the back of the waitint, behind any students that are already there. The student can only be waitiated at there is apare capacity. If not, the student's moliment request is grond When a student is dropped from the course, their removed from the collection enrolled students. If that frees up space in the class, the first student in line in the waitlist should automatically be led students in the waiti and is trapped from the con, that request is ignored The Classroom can provide lists of student names when requested for those that are mrolled and those that are waitinted. The set of ervolled students and the waths we should not be modified in any way when these names are requested. You can use a formach lots process each element in a collection for (int id: waltstid) Use there You must see the collections provided for you in the list of instances fregisteredStudents, enrolledIds and wastlistids You cannot change any of the method sipratures a method rames parameters and return type if you've implemented the base version correctly, the names of enrolled students printed should include everything from "lice through Geen catifexcept for and However, the order theyre printed will not beinhabetical order. The wait should have "Rupert," Serena, and have just learned that speed Queen Latifa incorrectly. My apologies Modified Version Make a modification to your implementation of the gentlistedets method to that return the list of student names in revene order to get full credit, you must use the Stack data structure Commit that change rate from the version implementation and somit to your implemented the modified version correctly, you should see the same printoutes above, except with the waitis printed in reverse order
Classroom.java
package edu.csc413.collections;
import java.util.*;
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 registerStudent(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
classroom.registerStudent(new Student(NAMES[i], IDS[i]));
}
// Attempt to enroll all students. This will go in alphabetical order by student name.
for (int i = 0; i
classroom.enrollStudent(IDS[i]);
}
// Attempt to drop a few students from the class, and re-enroll one.
classroom.dropStudent(IDS[4]); // Eli
classroom.dropStudent(IDS[17]); // Rupert (not enrolled)
classroom.dropStudent(IDS[10]); // Klay
classroom.enrollStudent(IDS[4]);
// Print out all enrolled students.
System.out.println("Enrolled students:");
for (String studentName:
classroom.getEnrolledStudents()) {
System.out.println(studentName);
}
System.out.println();
// Print out all enrolled students.
System.out.println("Waitlist:");
for (String studentName: classroom.getWaitlistedStudents()) {
System.out.println(studentName);
}
System.out.println();
}
// List of names and IDs used to generate Student data in main.
private static final String[] NAMES = {
"Alice", "Buster", "Carol", "Davante", "Eli", "Fiona", "Gob", "Harold", "Ian", "Jesse", "Klay", "Lindsay",
"Maebe", "Nelly", "Oscar", "Parmesan", "Queen Latifa", "Rupert", "Serena", "Tobias", "Uma", "Viggo",
"Wyatt", "Xavier", "Yoda", "Zoey",
};
private static final int[] IDS = {
200, 201, 202, 203, 199, 198, 197, 147, 148, 149, 150, 151, 276,
275, 274, 273, 272, 233, 234, 235, 236, 237, 172, 171, 170, 169,
};
}
Student.java
package edu.csc413.collections;
/**
* Represents a student that can be registered for, enrolled in, and dropped from the class. For the sake of simplicity,
* a student consists of just their name and ID.
*/
public class Student {
private final String name;
private final int id;
public Student(String name, int id) {
this.name = name;
this.id = id;
}
public String getName() {
return name;
}
public int getId() {
return id;
}
}
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