Question: 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

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!