Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

public class Course { private int CourseId; private String CourseName; private String Description; private int creditHours; public Course() { } public Course(int courseId, String courseName,

public class Course { private int CourseId; private String CourseName; private String Description; private int creditHours;

public Course() { }

public Course(int courseId, String courseName, String description, int creditHours) { CourseId = courseId; CourseName = courseName; Description = description; this.creditHours = creditHours; }

public int getCourseId() { return CourseId; }

public void setCourseId(int courseId) { CourseId = courseId; }

public String getCourseName() { return CourseName; }

public void setCourseName(String courseName) { CourseName = courseName; }

public String getDescription() { return Description; }

public void setDescription(String description) { Description = description; }

public int getCreditHours() { return creditHours; }

public void setCreditHours(int creditHours) { this.creditHours = creditHours; } public void display() { System.out.println("Course{" + "CourseId=" + CourseId + ", CourseName='" + CourseName + '\'' + ", Description='" + Description + '\'' + ", creditHours=" + creditHours + '}'); } }

Add 2 constructors to the Course class. One that takes no arguments and initializes the data to all 0s and (empty strings). And one constructor that takes all 4 arguments, one argument for each property and then sets the properties to these arguments that are passed in. Lastly change the main to use these new Constructors. You will not need to call the set functions any more, but do not remove the set functions from your class.

Main Code

Course c1;

c1 = new Course(323, Intro to Php, Intro to Php Programming, 4);

c1.display();

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

Samsung Galaxy S23 Ultra Comprehensive User Manual

Authors: Leo Scott

1st Edition

B0BVPBJK5Q, 979-8377286455

More Books

Students also viewed these Databases questions

Question

d. What is the WACC for Firm U? For Firm L?

Answered: 1 week ago

Question

Have I incorporated my research into my outline effectively?

Answered: 1 week ago