question archive CSE 214 – Data Structures Homework 2 – Spring 2022 Homework 2 – due Saturday, March 26 2022, no later than 11:59 PM EST Problem: Concert Security Total Points: 50 Imagine you’re a software developer for a stadium where your favorite K-pop group, TWICE, is having a concert

CSE 214 – Data Structures Homework 2 – Spring 2022 Homework 2 – due Saturday, March 26 2022, no later than 11:59 PM EST Problem: Concert Security Total Points: 50 Imagine you’re a software developer for a stadium where your favorite K-pop group, TWICE, is having a concert

Subject:Computer SciencePrice:22.99 Bought3

CSE 214 – Data Structures Homework 2 – Spring 2022 Homework 2 – due Saturday, March 26 2022, no later than 11:59 PM EST Problem: Concert Security Total Points: 50 Imagine you’re a software developer for a stadium where your favorite K-pop group, TWICE, is having a concert. Before a person gets into the concert, there is a security check with n lines where n decreases or increases depending on the available staff. The stadium needs to manage all lines and needs your help. Construct a program which manages all lines while maintaining the following conditions: 1. A person stands in line in ascending order corresponding to their seat number 2. All lines must be balanced, with each line having a difference in length of at most 1 person AT ALL TIMES Because n is flexible, both lines and concert attendees must be managed using singly linked lists you’ve designed yourself (DO NOT use an ArrayList). So, just as you might add a person to a line represented through a linked list, you might need to add a line to a set of lines also represented through a linked list. At the start of the concert (and your program), n = 1. Your program must run on its own and should not crash. Use exception handling as required. If your program does not compile, you will receive a 0 for it. You have to write all the CODE BY YOURSELF. Any form of plagiarism will result in 0 in the homework and possibly even a Q for the course. Required Classes and More: The following classes are required for this problem. Each class provides a description and the specifications necessary to complete its implementation. If you feel that additional methods or variables would be useful, feel free to add them during your implementation as you see fit. However, all the variables and methods in the following specifications must be included in your homework. You should declare the data fields of the classes as private and should provide the public getter and setter methods if required. Additionally, “fully documented classes” are classes which have enough reasonable comments and documentation for TAs and the professor to understand your implementation of this assignment. There is no strict criteria, but at the minimum you must include comments that describe crucial steps of computation within your implementation. 1. Person (Linked List Node) Points: 10 Write a fully documented class named Person that contains ticket information of each person and references the next person in line. The Person class should contain variables for the person’s name, seat number, and next person in line. ? public Person() constructor and also public Person(…parameters as needed…) ? One String variable: o name ? One int variable: o seatNumber ? One Person variable o nextPerson ? Getters and setters for all members. 2. Line (Linked List and Linked List Node) Points: 15 Write a fully documented class named Line that contains people waiting in line in ascending seat order. The Line class should contain a Person reference to the start of your line and its length. Additionally, each line should reference the next available line in your set of n lines. ? public Line() constructor ? Two Person variables o headPerson o tailPerson ? One int variable: o length • One Line variable o lineLink ? public void addPerson(Person attendee) o Brief: ? Adds a person to a line while maintaining condition 1. o Parameters: ? attendee – person to be added. o Preconditions ? None. o Postconditions ? The person is added to the list in ascending order. o Returns ? None. o Throws ? None. ? public Person removeFrontPerson() o Brief: ? Removes the person at the front of the line. o Parameters: ? None. o Preconditions ? Line is not empty. o Postconditions ? The next person from list is removed from the list. o Returns ? Person removed from the list. o Throws ? None. 3. SecurityCheck (Linked List) Points:15 Write a fully documented class named SecurityCheck that contains all lines and is able to increase/decrease the number of lines available. The SecurityCheck class should contain a reference to your first line and your number of available lines. ? Public SecurityCheck() constructor • Three Line variables o headLine o tailLine o cursorLine ? One int variable: o lineCount ? public void addPerson(String Name, int seatNumber) o Brief: ? Adds a person to a line while maintaining condition 2. o Parameters: ? name – Name of the person to be added. ? seatNumber – The number of this attendee’s seat o Preconditions ? The person’s seat number is found in any line. o Postconditions ? The person is added to the list that maintains condition 2. o Returns ? None. o Throws ? TakenSeatException: Thrown if a person’s seat number is found in any line. ? public Person removeNextAttendee() o Brief: ? Removes the person from the list with the lowest seat number that allows you to maintain condition 2 (may not have the absolute lowest seat number). o Parameters: ? None. o Preconditions ? All Lines are not empty. o Postconditions ? The person from the list with the lowest seat number that maintains condition 2 is removed. o Returns ? Person removed from security check lines. o Throws ? AllLinesEmptyException: Thrown if all lines are empty but a next person is requested. ? public void addNewLines(int newLines) o Brief: ? Adds new lines while maintaining conditions 1 and 2. o Parameters: ? newLines – The number of lines to add o Preconditions ? None. o Postconditions ? The number of available lines is adjusted while maintaining conditions 1 and 2. o Returns ? None. o Throws ? InvalidLineCountException: Thrown if newLines is negative. ? public void removeLines(int[] removedLines) o Brief: ? Removes lines while maintaining conditions 1 and 2. o Parameters: ? removedLines – An array containing the indices of lines removed (indices start at 1) o Preconditions ? Lines must exist or not remove a single available line. o Postconditions ? The number of available lines is adjusted while maintaining conditions 1 and 2. o Returns ? None. o Throws ? LineDoesNotExistException: Thrown if a line does not exist ? SingleLineRemovalException: Thrown if one attempts to remove the only line available. 3. SecurityManager Points: 10 Write a fully documented class named SecurityManager. This class will allow the stadium staff to queue new attendees and adjust the number of lines available. ? Must contain your main method o public static void main (String [] args) ? One SecurityCheck variable o securityCheck ? This method should implement the following menu options: o (A) – Add Person o (N) – Next Person o (R) – Remove Lines o (L) – Add New Lines o (P) – Print All Lines o (Q) – Quit Sample Input / Output // Comment in green, input in red, output in black Example: Adding a Person Starting... Line 1: 0 People Waiting Menu: (A) – Add Person (N) – Next Person (R) – Remove Lines (L) – Add Lines (P) – Print All Lines (Q) – Quit Please select an option: A Please enter a name: Jennifer Mejia // provided by the user Please enter a seat number: 5 Loading... Jennifer Mejia successfully added to line 1! Line 1: 1 Person Waiting // note the Person vs. People here Menu: (A) – Add Person (N) – Next Person (R) – Remove Lines (L) – Add Lines (P) – Print All Lines (Q) – Quit Example: Adding a Line(s) Line 1: 6 People Waiting Menu: (A) – Add Person (N) – Next Person (R) – Remove Lines (L) – Add Lines (P) – Print All Lines (Q) – Quit Please select an option: L Add how many more lines?: 2 Loading... Lines 2 and 3 introduced! // Your rebalanced lines may contain different people depending on your implementation Line 1: 2 People Waiting Line 2: 2 People Waiting Line 3: 2 People Waiting Menu: (A) – Add Person (N) – Next Person (R) – Remove Lines (L) – Add Lines (P) – Print All Lines (Q) – Quit Example: Printing all Line(s) Line 1: 2 Person Waiting Line 2: 2 People Waiting Line 3: 2 People Waiting Menu: (A) – Add Person (N) – Next Person (R) – Remove Lines (L) – Add Lines (P) – Print All Lines (Q) – Quit Please select an option: P Loading... // Please have it look similar to your table from HW1 | Line | Name | Seat Number | ============================================================== | 1 | James Haverdish | 7 | | 1 | Kyril Zlotnikov | 8 | | 2 | Alan Turing | 2 | | 2 | Jennifer Mejia | 5 | | 3 | Min-Gi Park | 4 | | 3 | James Bond | 9 | Line 1: 2 Person Waiting Line 2: 2 People Waiting Line 3: 2 People Waiting Menu: (A) – Add Person (N) – Next Person (R) – Remove Lines (L) – Add Lines (P) – Print All Lines (Q) – Quit Example: Getting Next Person Line 1: 2 People Waiting Line 2: 3 Person Waiting Line 3: 2 Person Waiting Line 4: 3 People Waiting Menu: (A) – Add Person (N) – Next Person (R) – Remove Lines (L) – Add Lines (P) – Print All Lines (Q) – Quit Please select an option: N Loading... Amadeus Mongus from seat 1 removed from line 2! Line 1: 2 People Waiting Line 2: 2 People Waiting Line 3: 2 People Waiting Line 4: 3 People Waiting Menu: (A) – Add Person (N) – Next Person (R) – Remove Lines (L) – Add Lines (P) – Print All Lines (Q) – Quit Example: Removing a Line(s) Line 1: 5 People Waiting Line 2: 6 People Waiting Line 3: 6 People Waiting Line 4: 6 People Waiting Line 5: 5 People Waiting Menu: (A) – Add Person (N) – Next Person (R) – Remove Lines (L) – Add Lines (P) – Print All Lines (Q) – Quit Please select an option: R Lines to remove: 1, 2, 4 Loading... Lines 1, 2, and 4 have been decommissioned! // Line i has been decommissioned! (if single line removed) // Your rebalanced lines may contain different people depending on your implementation Line 1: 13 People Waiting Line 2: 14 People Waiting Menu: (A) – Add Person (N) – Next Person (R) – Remove Lines (L) – Add Lines (P) – Print All Lines (Q) – Quit Example: Invalid Input Line 1: 1 People Waiting Line 2: 2 People Waiting Line 3: 2 People Waiting Menu: (A) – Add Person (N) – Next Person (R) – Remove Lines (L) – Add Lines (P) – Print All Lines (Q) – Quit Please select an option: R Remove which lines? 4 The input you entered is incorrect. Please try again! Advice • You may want to implement printing all available lines as soon as possible. Doing so will let you make sure you are abiding by the two balancing conditions established for this assignment. • As mentioned previously, the next person removed by Security manager is not necessarily the person with the lowest seat number. Strictly removing the person with the lowest seat number of any available line may break condition 2. • You may want to adjust cursorLine as you add, remove, or rearrange people among lines.

Option 1

Low Cost Option
Download this past answer in few clicks

22.99 USD

PURCHASE SOLUTION

Option 2

Custom new solution created by our subject matter experts

GET A QUOTE

rated 5 stars

Purchased 3 times

Completion Status 100%