Answered step by step
Verified Expert Solution
Question
1 Approved Answer
PART A - LinkedLists ( 5 5 marks ) When a student wishes to register for a course, they are placed on a waitlist if
PART A LinkedLists marks
When a student wishes to register for a course, they are placed on a waitlist if the class is already full.
Students can register from the waitlist when a spot become available and if they have permission. In our
simplified simulation of a waitlist, the system randomly performs one of four operations and updates the
waitlist accordingly. For simplicity, we assume that:
only one operation can be performed in a day;
a waitlisted student has a maximum of two days to complete their registration once they are
permitted to register. If not registered after two days, the student becomes the last person on
the list, in order to give other students a chance;
only one student first person on the list can be granted permission to register at any point.
A waitlisted student is a student with a waitlist status Waitlisted or PermittedToRegister and
may have some number of days left to complete registration if they have been permitted to
register.
The details of each operation and the rules applying are provided below:
Operation : No addition to the waitlist
This operation does not change the number of students on the waitlist but an existing status or days left
to register may be changed for a student with permission to register, or the first student may be granted
permission to register if no one previously had permission.
Operation : A new student joins the waitlist
Details of the student must be provided and the student added to the waitlist. A new student is always
added to the end of the list with a Waitlisted status. An existing status or days left to register may be
changed after adding the new student or the first student may be granted permission to register if no one
previously had permission.
Operation : The first waitlisted student registers
First student registers if they already had permission, otherwise, they are granted permission to register.
Operation : Check if a student is on the waitlist.
Details of the student to check in the list must be provided and the result of the search displayed. An
existing status or days left to register may be changed after the check or the first student may be granted
permission to register if no one previously had permission. Two students are considered the same if they
have the same student number and name.
The simulation randomly chooses one of these operations until the waitlist is empty or operations have
been performed randomly. You are expected to do the following to complete the simulator.
Program the generic CircularDoublyLinkedList class. See appendix for CDLL representation.
Use the circularly and doubly linked list classes from our notes as a basis.
Start with the DLL and think of how it can work circularly.
Sentinels are not required, only reference to the last node.
Node will have references to the next and previous nodes.
addBetween and remove private utilities will be used, all adding and removing will
work like doubly.
Your CircularlyDoublyLinkedList class will support the following public methods:
size Returns the number of elements in the list.
isEmpty Returns true if the list is empty, and false otherwise.
first Returns but does not remove the first element in the list.
last Returns but does not remove the last element in the list.
addFirste Adds a new element to the front of the list.
addLaste Adds a new element to the end of the list.
removeFirst Removes and returns the first element of the list.
removeLast Removes and returns the last element of the list.
rotate Advances to the next element in the list.
containse Returns true if e is in the list, and false otherwise
Create the following classes:
a Student stores the student number and name of a student. Include an equals method to
check if an object is the same as an instance of the student. Two students are considered the
same if they have the same student number and name Include any methods required to retrieve
student details.
b WaitlistedStudent is a type of Student that has a Status and some number of days
left to register.
Add a constructor that works the same way that a Student is created but initializes the
registration status to Waitlisted and the number of days left to register to
Add a constructor that allows the number of days left to register to be specified
Include any methods required to retrieve or update the status or number of days left to
register.
Status is an enum type: Waitlisted, PermittedToRegister
c CourseWaitlist class that simulates the random operation on a course waitlist with some
waitlisted students.
Note: most of the work will be done here. AssignPartADriver should have only a
minimal amount of code: eg declarecreate a CourseWaitlist instance, create initial
waitlisted students, and initiate the course waitlist simulation.
Fields
a CircularDoublyLinkedList of waitlisted students
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