Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

java Lab Exercise: Implement the following classes: 1. class Course that includes two instance variables: private String Name; // the course name // the course

java image text in transcribed
image text in transcribed
image text in transcribed
Lab Exercise: Implement the following classes: 1. class Course that includes two instance variables: private String Name; // the course name // the course ID private int 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 deptName; private Course CRS[]; private int noofCourses; Your class should have the following: a constructor that initializes the department name, set noofCourses and creates the array with size = noofCourses 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. 4 void printCoursesRecursively () 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 LablTest. 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. Sample Output Please enter the department name: Computer Engineering Department Please enter the maximum number of courses in the department: 20 How many courses do you have? Enter course 1 id: 200 Enter course 1 name: C++ Programming Enter course 2 id: 201 Enter course 2 name: Java Progranning Enter course 3 id: 207 Enter course 3 name: Data Structures Courses in Computer Engineering Department are: 1- 200 C++ Progranning 2- 201 Java Programning 3 - 207 Data Structures Using recursive print method. Courses in Computer Engineering Department are: 1- 200 C++ Progranming 2 - 201 Java Programming 3- 207 Data Structures Enter a course id to be deleted: 201 The course with the ID- 201 was deleted. Courses in Computer Engineering Department are: 1- 200 C++ Progranning 2 - 207 Data Structures Enter a course id to search for: 201 The course with the ID = 201 does not exist in the department list How many additional courses do you have? 4 Enter course 1 id: 216e Enter course 1 name: Computer Ethics Enter course 2 id: 262 Enter course 2 name: Fundamentals of Digital Logic Enter course 3 id: 300 Enter course 3 name: Design and Analysis of Algorithms Enter course 4 id: 325 Enter course 4 name: Human-Computer Interaction Courses in Computer Engineering Department are: 1- 200 C++ Progranming 2 - 210 Computer Ethics 3 - 207 Data Structures 4 - 262 Fundamentals of Digital Logic 5- 300 Design and Analysis of Algorithms 6 - 325 Human -Computer Interaction 6

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

Practical Database Programming With Visual C# .NET

Authors: Ying Bai

1st Edition

0470467274, 978-0470467275

More Books

Students also viewed these Databases questions