Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.)

image text in transcribed

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

image text in transcribed

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

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

Step: 3

blur-text-image

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

Building Database Driven Catalogs

Authors: Sherif Danish

1st Edition

0070153078, 978-0070153073

More Books

Students also viewed these Databases questions

Question

LO6.1 Discuss price elasticity of demand and how it is calculated.

Answered: 1 week ago