solution for remove(int id) removes the Student (classt type) associated with this id; if the id is not found in the table or on the waitlist, then it should return null; otherwise, it should return the Student associated with the id. If the student that is removed was registered, then this student sh

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Implement solution for remove(int id)

removes the Student (classt type) associated with this id; if the id is not found in the table or on the waitlist, then it should return null; otherwise, it should return the Student associated with the id. If the student that is removed was registered, then this student should be replaced by the student who is first in the waitlist queue. If the student who is removed was on the waitlist, then they should just be removed from the waitlist. You should go directly to slot id % m rather than iterating through all the slots.

****note that return is null****

 

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 Student remove(int id) {
        // insert your solution here and modify the return statement
        return null;

Student.java
oublic class Student {
public int id;
public String name;
public SLinkedList<String> courseCodes;
public final int COURSE_CAP
3;
%3D
public Student(int id, String name) {
this.id = id;
this.name = name;
this.courseCodes = new SLinkedList<String>();
}
public boolean isRegistered0rWaitlisted (String course) {
return this.courseCodes.getIndex0f(course) > -1;
}
public void addCourse(String course) {
this.courseCodes.addLast(course);
}
public void dropCourse(String course) {
this.courseCodes.remove(course);
}
public String toString(){
return "#" + this.id +
: " + this.name;
}
Transcribed Image Text:Student.java oublic class Student { public int id; public String name; public SLinkedList<String> courseCodes; public final int COURSE_CAP 3; %3D public Student(int id, String name) { this.id = id; this.name = name; this.courseCodes = new SLinkedList<String>(); } public boolean isRegistered0rWaitlisted (String course) { return this.courseCodes.getIndex0f(course) > -1; } public void addCourse(String course) { this.courseCodes.addLast(course); } public void dropCourse(String course) { this.courseCodes.remove(course); } public String toString(){ return "#" + this.id + : " + this.name; }
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY