erwise, 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

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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.

 

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;
    }

public String tostring() {
30
4
String s = "Course: "+ this.code +"\n";
S +=
-\n";
for (int i = 0; i < this.studentTable.length; i++) {
|\n";
s += "|"+i+"
s += "|
SLinkedList<Student> list = this.studentTable[i];
if (list != null) {
for (int j = 0; j < list.size(); j++) {
------> ":
Student student = list.get(j);
S +=
student.id + ": "+ student.name +" --> ";
4
}
}
S += "\n-
--\n\n";
}
return s;
}
}
1
Transcribed Image Text:public String tostring() { 30 4 String s = "Course: "+ this.code +"\n"; S += -\n"; for (int i = 0; i < this.studentTable.length; i++) { |\n"; s += "|"+i+" s += "| SLinkedList<Student> list = this.studentTable[i]; if (list != null) { for (int j = 0; j < list.size(); j++) { ------> ": Student student = list.get(j); S += student.id + ": "+ student.name +" --> "; 4 } } S += "\n- --\n\n"; } return s; } } 1
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

Blurred answer
Knowledge Booster
Concept of Threads
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education