Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In java In the previous challenge, you wrote two custom exceptions: InvalidStudentNameException and InvalidDescriptionException. In this challenge, we have included our own correct implementations of

image text in transcribedIn java

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 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 ticketID of 1, the second ever HelpTicket object should have a ticket ID 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 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 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 ticketID of 1, the second ever HelpTicket object should have a ticket ID 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

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_2

Step: 3

blur-text-image_3

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

Advances In Databases And Information Systems 25th European Conference Adbis 2021 Tartu Estonia August 24 26 2021 Proceedings Lncs 12843

Authors: Ladjel Bellatreche ,Marlon Dumas ,Panagiotis Karras ,Raimundas Matulevicius

1st Edition

3030824713, 978-3030824716

More Books

Students also viewed these Databases questions