Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Instructions - Submit your. java files (together in a Assign1. zip file) via Nexus. - Include your name and student number as a comment in

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Instructions - Submit your. java files (together in a Assign1. zip file) via Nexus. - Include your name and student number as a comment in every file. - Document the classes using Javadoc notation. - Include comments as needed and use exception handling where necessary. 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 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. 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. 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. Assign1PaxtA_Driver should have only a minimal amount of code: e.g., declare/create a coursewait 1 st instance, create initial waitlisted students, and initiate the course waitlist simulation. - Fields a CircularDoublyLinkedLi st of waitlisted students - any other field required to manage the game - Upon instantiation, set up the initial list of waitlisted students (use 4 initial waitlisted students for your demo/sample data) and grant the first student permission to register (when a student is granted permission, they have two days to register). Begin the simulation. - The simulation randomly chooses one of the operations and continues until the list is empty or 20 operations have been performed. - After each operation, the list of students on the waitlist is displayed together with the waitlist status and the number of days left to register (if they have permission to register). - When the simulation stops, the termination condition of the simulation is displayed and the final waitlist is also displayed. 3. Create a driver class called Assign1 PartA__river that invokes a simulation of the course waitlist using a list of four waitlisted students of your choice

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

Microsoft Visual Basic 2008 Comprehensive Concepts And Techniques

Authors: Gary B. Shelly, Corinne Hoisington

1st Edition

1423927168, 978-1423927167

More Books

Students also viewed these Databases questions

Question

Describe new developments in the design of pay structures. page 475

Answered: 1 week ago