Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

ANSWER ALL PARTS IN JAVA PLEASE Part 1 Part 2 Part 3 ANSWER ALL PARTS IN JAVA PLEASE In the previous challenge, you wrote two

ANSWER ALL PARTS IN JAVA PLEASE

Part 1

image text in transcribedimage text in transcribed

Part 2

image text in transcribedPart 3

image text in transcribedANSWER ALL PARTS IN JAVA PLEASE

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 studentName to store the student's name, String description to store the description, and int ticketID 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 ticket ID 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 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 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 LabQueueNode 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 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 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 studentName to store the student's name, String description to store the description, and int ticketID 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 ticket ID 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 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 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 LabQueueNode 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 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

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 An Application Oriented Approach Complete Version

Authors: Michael Kifer, Arthur Bernstein, Richard Lewis

2nd Edition

0321268458, 978-0321268457

More Books

Students also viewed these Databases questions