Question: Implement the following classes: 1. class Course that includes two instance variables: private String Name; // the course name private int ID; // the
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. toString method that returns a String representation of the Course as (ID Name) 2. class Department that includes three instance variables: private String deptName; private Course CRS[]: private int noofCourses: Your class should have the following: . a constructor that initializes the department name, set noorCourses and creates the array with size noofCourses public boolean exist(int id) that checks whether the course object with id passed as parameter exists in the array or not. public void addCourse (int id, String name) creates and adds the course if the course with id passed as parameter does not exist in the array. public void deleteCourse (int id) to delete a course if it exists in the array and displays a proper message. public void printCourses () that prints the department name and all the courses in the array. public void printCoursesRecursively () that prints the department name and all the courses in the array recursively. [Hint: write an additional private helper method] public Course maxRecursive () that searches the courses array in the department class for the course with max id. [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.
Step by Step Solution
There are 3 Steps involved in it
It appears you have an assignment to implement two classes Course and Department Below are the implementations for the classes based on the requiremen... View full answer
Get step-by-step solutions from verified subject matter experts
