Question: Define a new class called Course, with attributes as follows, Attributes: - courseId (String) - courseTitle (String) - creditHours (int) All the three attributes courseId,

Define a new class called Course, with attributes as follows,

Attributes:

- courseId (String)

- courseTitle (String)

- creditHours (int)

All the three attributes courseId, courseTitle, and creditHours must be declared by following the encapsulation principle.

For each of the three attributes, also write a getter and a setter method.

At least one of the setter method must use the this keyword in its method body.

Constructors:

The default constructor (should set courseId = "", courseTitle = "", creditHours = 0)

The "init" constructor (imput parameters: courseId, courseTitle, creditHours)

Creating an Array and for loop on Test Driver

Write a test driver called TestCourse.java that instantiates an array of Course objects with the following details:

1st element: courseId = "CS101", courseTitle = "Introductory Computer Science", creditHours = 3

2nd element: courseId = "CS102", courseTitle = "Data Structures", creditHours = 3

3rd element: courseId = "CS103", courseTitle = "C++ Programming", creditHours = 4

The Test Driver should then display the list of courses offered as follows. (Don't worry about the formatting and columnar alignment.)

Define a new class called Course, with attributes as follows, Attributes: -

Lastly, I've included a rubric to show what needs to be in the Course.java class and TestCourse.java class:

courseId (String) - courseTitle (String) - creditHours (int) All the three attributes

Courses Offered Course ID Course Title Credit Hrs cs101 CS102 CS103 Introductory Computer Science Data Structures C++ Programming 3 3

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!