Implement solutions for the following methods: • getCourseSize() – returns the number of students registered in the course (not in the waitlist). It should maintain the public size variable that keeps track of the number of students registered. • getRegisteredIDs() – returns an array of int[], namely registered student id’s. The length of the array is the size (number of students) in the course. • getRegisteredStudents() – returns an array of type Student[], namely the registered Students. The length of the array is the current size (number of students) of the course. • getWaitlistedIDs() – returns an array of type int[], namely the ids of students in the waitlist. • getWaitlistedStudents() – returns an array of Students in the waitlist.
Implement solutions for the following methods:
• getCourseSize() – returns the number of students registered in the course (not in the waitlist). It should maintain the public size variable that keeps track of the number of students registered.
• getRegisteredIDs() – returns an array of int[], namely registered student id’s. The length of the array is the size (number of students) in the course.
• getRegisteredStudents() – returns an array of type Student[], namely the registered Students. The length of the array is the current size (number of students) of the course.
• getWaitlistedIDs() – returns an array of type int[], namely the ids of students in the waitlist.
• getWaitlistedStudents() – returns an array of Students in the waitlist.
public class Course {
public String code;
public int capacity;
public SLinkedList<Student>[] studentTable;
public int size;
public SLinkedList<Student> waitlist;
public Course(String code) {
this.code = code;
this.studentTable = new SLinkedList[10];
this.size = 0;
this.waitlist = new SLinkedList<Student>();
this.capacity = 10;
}
public Course(String code, int capacity) {
this.code = code;
this.studentTable = new SLinkedList[capacity];
this.size = 0;
this.waitlist = new SLinkedList<>();
this.capacity = capacity;
}
public int getCourseSize() {
// insert solution here and modify the return statement
return -1;
}
public int[] getRegisteredIDs() {
// insert solution here and modify the return statement
return null;
}
public Student[] getRegisteredStudents() {
// insert solution here and modify the return statement
return null;
}
public int[] getWaitlistedIDs() {
// insert solution here and modify the return statement
return null;
}
public Student[] getWaitlistedStudents() {
// insert solution here and modify the return statement
return null;
}
Step by step
Solved in 2 steps