Computer Networking: A Top-Down Approach (7th Edition)
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
Bartleby Related Questions Icon

Related questions

Question

Need help writing the following method: get(int id)

– returns a Student, assuming that the student is either registered for the course or on the waitlist. If there is no student in the table or waitlist that has this id, get() should return null. You should go directly to slot id % m rather than iterating through all the slots. 

 

For context

 

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;

    }

1 public class Student I
2
public int id;
public String name;
public SLinkedList<String> courseCodes;
3
4
6.
public final int COURSE_CAP
= 3;
%3D
7
public Student(int id, String name) {
this.id = id;
this.name = name;
this.courseCodes = new SLinkedList<String>();
}
86
9
%3D
10
11
12
13
140
15
16
17
180
19
20
21
220
23
24
25
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 + "
}
260
" + this. name;
27
28
29
30 H
expand button
Transcribed Image Text:1 public class Student I 2 public int id; public String name; public SLinkedList<String> courseCodes; 3 4 6. public final int COURSE_CAP = 3; %3D 7 public Student(int id, String name) { this.id = id; this.name = name; this.courseCodes = new SLinkedList<String>(); } 86 9 %3D 10 11 12 13 140 15 16 17 180 19 20 21 220 23 24 25 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 + " } 260 " + this. name; 27 28 29 30 H
Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Similar questions
Recommended textbooks for you
Text book image
Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON
Text book image
Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science
Text book image
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning
Text book image
Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning
Text book image
Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education
Text book image
Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY