Answered step by step
Verified Expert Solution
Link Copied!

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 (55 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 1: 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 2: 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 3: The first waitlisted student registers
First student registers if they already had permission, otherwise, they are granted permission to register.
Operation 4: 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.
2
The simulation randomly chooses one of these operations until the waitlist is empty or 20 operations have
been performed randomly. You are expected to do the following to complete the simulator.
1. 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.
addFirst(e) Adds a new element to the front of the list.
addLast(e) 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.
contains(e) Returns true if e is in the list, and false otherwise
2. 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 0.
- 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. Assign1PartA_Driver should have only a
minimal amount of code: e.g., declare/create 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems For Advanced Applications 27th International Conference Dasfaa 2022 Virtual Event April 11 14 2022 Proceedings Part 2 Lncs 13246

Authors: Arnab Bhattacharya ,Janice Lee Mong Li ,Divyakant Agrawal ,P. Krishna Reddy ,Mukesh Mohania ,Anirban Mondal ,Vikram Goyal ,Rage Uday Kiran

1st Edition

3031001257, 978-3031001253

More Books

Students also viewed these Databases questions

Question

Distinguish between hearing and listening.

Answered: 1 week ago

Question

Use your voice effectively.

Answered: 1 week ago