Question: Data Structures in java .ll stc KW LTE 9:34 AM newocs.eng.ku.edu.kw 9 * 55% Common Mistakes: Trying to access a method when a reference is

.ll stc KW LTE 9:34 AM newocs.eng.ku.edu.kw 9 * 55% Common Mistakes: Trying to access a method when a reference is pointing to null. Lab Exercise: Implement the following classes: 1. class course that includes three instance variables: private String Name: // the course name private int ID: 1/ the course ID private Course next: // the link Your class should have the following: A constructor that initializes the two instance variables id and name Set and get methods for each instance variable. 2. class Department that includes three instance variables: private String dept Name: private Course head, tail: Your class should have the following: a constructor that initializes the department name public boolean exist(int id) that checks whether the course object with id passed as parameter exists in the list or not. public boolean insert(int id, String n) that creates and adds the course if the course with id passed as parameter does not exist in the list. The course must be added in ascending order. The method will return false if the id was a duplicate. public boolean remove(int id) that deletes a course if it exists in the list and returns true. The method will return false if the id was not found in the list. public String findCourse (int id) that returns a course name if the id exists in the list. public void print() that prints the department name and all the courses in the array. Write the expected time and space complexity as a comment at the 4 55% ..il stc KW LTE 9:34 AM newocs.eng.ku.edu.kw courses in the array. 13 of 72 Write the expected time and space complexity as a comment at the beginning of each method of your class. 3. Write a test application named Lab Test. In the main method, do the following: Input the department name then create a department object. Display a menu to the user and asking for a choice to be entered. As follows: The program can perform the following: 1- insert a course 2- remove a course 3- Search for a course 4- print courses 5- exit Please enter your selection: The program will perform the action selected by the user and display a proper message when necessary. The program will repeat these actions until the user terminates the program (Hint: Use a loop)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
