Question: java java I stc KW LTE 10* 83% 9:26 PM kuwebcont.ku.edu.kw Additional Exercise: Implement the following classes: 1. Class Car that includes the following instance




I stc KW LTE 10* 83% 9:26 PM kuwebcont.ku.edu.kw Additional Exercise: Implement the following classes: 1. Class Car that includes the following instance variables: private int plateNumber // the car plate number private int year Model // the car year model private string color // the car color The class should have the following: A constructor that initializes the three instance variables. Set and get methods for each instance variable. 2. class CarService that includes two instance variables: private Array named carsArray of type Car. Private int data field named maxSize for the array size. The class should have the following: A constructor that initializes the maxSize and creates the array. boolean search (int) that checks whether the Car object with plate number passed as a parameter exists in the array or not. boolean add (int,int, String) that creates and adds a Car object to the array if the car plate number passed as parameter does not exist in the array and if the array is not full Car service() that removes the first Car from the array, shifts the array content to the left and returns the removed Car object. If the array is empty, the method returns null void print that prints all cars in the array. 3. Write a test application named CarTest. In the main method, do the following: Create a Car Service object with max size = 5. Display a menu of choices as shown in the sample output. Follow the sample output to test all methods. Stop the program when the user enters choice 5. Sample Output ll stc KW LTE 10* 83% 9:26 PM kuwebcont.ku.edu.kw Sample Output Enter your choice 3. Print available cars 4. Search for a Car Inter Car plate number or -1 to Stop: Enter Year Model: Enter Car colors Enter Car plate number or -1 to Stop: Enter Year Model: Enter Car color: Enter Car plate number or -1 to Stop: Enter Year Model: Enter Car color: Enter Car plate number or -1 to Stop: 1. Add cars 2. Service a car 3. Print available cars 4. Search for a Car 5. Exit Car Plate Number Year Model Color 2014 Blue 67890 98765 1. A cars 2. Service a car 3. Print available cars 4. Search for a Car 12345 car has been serviced 2. Service a car 3. Perint available cars 4. Search for a Car .ll stc KW LTE 10 * 83% 9:26 PM kuwebcont.ku.edu.kw 4. Search for a Car Enter the car plate number: The car was not found 1. Add cars 2. Service a car 3. Print available cars 4. Search for a Car 5. Exit Color Car Plate Number 67890 98765 Year Model 2014 2008 51 1. Add cars 2. Service a car 3. Print available cars 4. Search for a Car void printCourses Recursively) that prints the department name and all the courses in the array recursively. (Hint: write an additional private helper method] 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 and maximum number of courses then create a department object. Input the number of courses in the first set. Input the id and name of each course and add it to the department (Hint: Use a loop). Print the courses. Print the courses using the recursive method. Input the id of a course to be deleted. Delete the course. Print the courses. Input the id of a course to check if it exists and print a proper message Input the id and name of an additional set of courses and add them to the department (Hint: Use a loop). Print the courses. Lab Exercise: Implement the following classes: 1. class Course that includes two instance variables: private String Name; // the course name private int ID; // the course ID 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 CRS[]; private int noof Courses ; Your class should have the following: . a constructor that initializes the department name, set noofCourses and creates the array with size = noorCourses boolean exist(int) that checks whether the course object with id passed as parameter exists in the array or not. void addCourse (int, String) creates and adds the course if the course with id passed as parameter does not exist in the array. void deleteCourse (int) to delete a course if it exists in the array and displays a proper message. void printCourses () that prints the department name and all the courses in the array. void printCourses Recursively) that prints the department name and all the courses in the array recursively. (Hint: write an additional private helper method] Write the expected time and snare complexity as a comment at the .ll stc KW LTE 10 * 83% 9:26 PM kuwebcont.ku.edu.kw 4. Search for a Car Enter the car plate number: The car was not found 1. Add cars 2. Service a car 3. Print available cars 4. Search for a Car 5. Exit Color Car Plate Number 67890 98765 Year Model 2014 2008 51 1. Add cars 2. Service a car 3. Print available cars 4. Search for a Car
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
