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.)
Lastly, I've included a rubric to show what needs to be in the Course.java class and TestCourse.java class:
Courses Offered Course ID Course Title Credit Hrs cs101 CS102 CS103 Introductory Computer Science Data Structures C++ Programming 3 3Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started