Answered step by step
Verified Expert Solution
Question
1 Approved Answer
in JAVA please do the following parts: please do as many parts. i will break this up into several posts, and hopefully youll be able
in JAVA please do the following parts:
For the rest of this PA, we will be building our own Lab Queue system step-by-step. Just like the one we use for CSE 11, we will want our Lab Queue to be able to store tickets, remove tickets, lock, etc. We will build it component-by-component, focusing on (and testing) each individual component one at a time. First, we need to design a class to represent tickets. Each ticket should be able to store a student name, a description, and a unique identifier. However, before we can actually write a class to represent tickets, we need to define our own custom exceptions to throw if the user were to misuse the class we create. TASK: Create two new exceptions, InvalidStudentNameException and InvalidDescriptionException, that both extend the Exception class. They must both have a constructor that has a single parameter of type String called message, which just calls the corresponding superclass constructor NOTE: Ignore the "Sample Input:" and "Sample Output:" sections immediately below this. They are always shown by Stepik, even if they're not used. The "CORRECT" message is something that is being used behind-the-scenes in the grading system. Sample Input: Sample Output: Invalid student name Invalid description Write a program, test using stdin stdout In the previous challenge, you wrote two custom exceptions: InvalidStudentNameException and InvalidDescriptionException. In this challenge, we have included our own correct implementations of both exceptions (the code is just hidden from you) TASK: Now that we have written some custom exceptions to handle some issues we might face when the user creates a ticket, we can actually design a class to represent the tickets themselves. Each ticket should be able to store a student name, a description, and a unique identifier. Write a HelpTicket class with the following properties: It should have 1 private static variable: int count, which stores the number of tickets that have ever been created. If no tickets have ever been created, it will be 0; after the first ticket has been created, it will be 1; etc. It should have 3 private final instance variables: String student Name to store the student's name, String description to store the description, and int ticket ID to store this ticket's ID It must have a public 2-parameter constructor that has a parameter of type String called studentName followed by a parameter of type String called description. It should do the following: If the studentName argument is null, it should throw an InvalidStudentNameException with the following message: "studentName cannot be null" (no quotes) If the studentName argument is the empty string (i.e., "), it should throw an InvalidStudentNameException with the following message: "studentName cannot be empty' (no quotes) If the description argument is null, it should throw an InvalidDescriptionException with the following message: "description cannot be null" (no quotes) If the description argument is the empty string (i.e.,), it should throw an InvalidDescriptionException with the following message: "description cannot be empty" (no quotes) It should set the studentName and description instance variables accordingly It should set the ticketID instance variable to be how many tickets have ever been created after the creation of this one. For example, the first ever HelpTicket object should have a ticket ID of 1, the second ever HelpTicket object should have a ticketID of 2, etc. It should also update the static count variable of the HelpTicket class It must have a public getter method for each of the 3 instance variables: getStudentName, getDescription, and getTicketID NOTE: Ignore the "Sample Input:" and "Sample Output:" sections immediately below this. They are always shown by Stepik, even if they're not used. The "CORRECT" message is something that is being used behind-the-scenes in the grading system. Sample Input: Niema Moshiri, Halp pls Gerald Soosai Raj, I need help Shreeman Hariharan, Help me! Laura Xu, Still stuck Utkrisht Rajkumar, Not sure what to do Sample Output: Niema Moshiri, Halp pls, 1 Gerald Soosai Raj, I need help,2 Shreeman Hariharan, Help me!, 3 Laura Xu, Still stuck, 4 Utkrisht Rajkumar, Not sure what to do, 5 student Name cannot be null student Name cannot be empty description cannot be null description cannot be empty Write a program, test using stdin stdout Now that we've created our HelpTicket class, which will represent submitted tickets, we can think about how we want to implement the actual Lab Queue. For this assignment, we will implement our Lab Queue by first building a custom Linked List data structure (specifically, a Singly-Linked List), which is a series of nodes linked together in some order. However, before we can actually write a class to represent nodes in our Linked List, we need to define our own custom exceptions to throw if the user were to misuse the node class we create. TASK: Create two new exceptions, NullTicketException and SelfNextException, that both extend the Exception class. They must both have a no-parameter constructor, which just calls the corresponding superclass constructor NOTE: Ignore the "Sample Input:" and "Sample Output:" sections immediately below this. They are always shown by Stepik, even if they're not used. The "CORRECT" message is something that is being used behind-the-scenes in the grading system. Sample Input: Sample Output: Write a program, test using stdin stdout In the previous challenges, you wrote some custom exceptions as well as a HelpTicket class. In this challenge, we have included our own correct implementations of all of these (the code is just hidden from you). TASK: Now that we have written some custom exceptions to handle some issues we might face when the user creates a new node, we can start building the components of our Linked List. Write a LabQueue Node class with the following properties: It should have 2 private instance variables: HelpTicket ticket to store the help ticket, and LabQueueNode nextNode to store a link to the next node It must have a public 2-parameter constructor that has a parameter of type HelpTicket called ticket followed by a parameter of type LabQueueNode called nextNode. It should set the ticket and nextNode instance variables accordingly, and if the ticket argument is null, it should throw a NullTicketException It must have a public constructor that has a parameter of type HelpTicket called ticket, and it should do the same thing as the 2-parameter constructor, except it should set the nextNode instance variable to null It must have a public getter method for each of the 2 instance variables: getTicket and getNextNode It must have a public setter for the nextNode instance variable: setNextNode. If the user tries to set a node as its own nextNode, this method must throw a SelfNextException NOTE: Ignore the "Sample Input:" and "Sample Output:" sections immediately below this. They are always shown by Stepik, even if they're not used. The "CORRECT" message is something that is being used behind-the-scenes in the grading system. Sample Input: Sample Output: Write a program, test using stdin stdout Now that we've created our LabQueueNode class, we're almost ready to write our Lab Queue system. However, before we can actually write a class to represent our Lab Queue, we need to define our own custom exceptions to throw if the user were to misuse it. TASK: Create four new exceptions, AddToLockedQueueException, RemoveFromEmptyQueueException, DoubleLockException, and DoubleUnlockException that all extend the Exception class. They must all have a no-parameter constructor, which just calls the corresponding superclass constructor NOTE: Ignore the "Sample Input:" and "Sample Output:" sections immediately below this. They are always shown by Stepik, even if they're not used. The "CORRECT" message is something that is being used behind-the-scenes in the grading system. Sample Input: Sample Output: Write a program, test using stdin stdout In the previous challenges, you wrote some custom exceptions and some custom classes. In this challenge, we have included our own correct implementations of all of these (the code is just hidden from you) TASK: Now that we have written some custom exceptions to handle some issues we might face when the user, we can build our actual Lab Queue. Write a LabQueue class with the following properties: It should have 4 private instance variables: LabQueueNode head to store the head (i.e., first) node, LabQueueNode tail to store the tail (i.e., last) node, int numTickets to store the current number of tickets in the Lab Queue, and boolean locked It must have a public no parameter constructor that initializes the instance variables to null, 0, and false accordingly It must have a no-parameter method called isLocked that returns the locked instance variable It must have a no-parameter method called size that returns numTickets It must have a no-parameter method called lock that changes locked from false to true. If locked was already true, the method must throw a DoubleLockException It must have a no-parameter method called unlock that changes locked from true to false. If locked was already false, the method must throw a DoubleUnlockException It must have a method called add that has one parameter of type HelpTicket called ticket. The method should create a new LabQueueNode containing ticket and make it the list's new tail (adjusting any nextNode references to keep the list functional). If the new LabQueueNode is the only node in the list, it should also become the list's head. The method should also increment numTickets. If locked was true before the method call, the method must throw an AddToLockedQueueException It must have a method called remove that has no parameters. The method should remove the list's head (adjusting any nextNode references to keep the list functional) and return the HelpTicket it contained. If no more LabQueueNode objects exist in the list, both head and tail should also be set to null. The method should also decrement numTickets. If the Lab Queue was empty before the method call, the method must throw a RemoveFromEmptyQueueException NOTE: Ignore the "Sample Input:" and "Sample Output:" sections immediately below this. They are always shown by Stepik, even if they're not used. The "CORRECT" message is something that is being used behind-the-scenes in the grading system please do as many parts. i will break this up into several posts, and hopefully youll be able to do all parts. will rate!!! thanks!
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