Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write the implementation of the class Course according to the requirements liste

ID: 3810874 • Letter: W

Question

Write the implementation of the class Course according to the requirements listed below. Data fields: o A String courseDept that stores the course department ("CS", "Math", etc.). o An int courseNo that stores the course number (170, 150, etc). o An int course Units that stores the number of units for the course o Remember that data fields are always private. Default constructor o Initializes all data fields to default values. Overloaded constructor o Parameters: a string storing the course department, an int storing the course number, and an int storing the number of units. o Initializes all data fields to the given values. Method getCourseDept o Returns the course department. Method get CourseNumber o Returns the course number. Method getCourseUnits o Returns the number of units for the course. Method setCourseDept o Parameter a String storing a course department. o Re-sets the course department of the calling object with the value passed by the parameter. Method setCourseNumber o Parameter: an int storing a course number. o Re-sets the course number of the calling object with the value passed by the parameter. Method setCourseUnits o Parameter: an int storing the units for the course. o Re sets the course units of the calling object with the value passed by the parameter. Method compareUnits o Parameter: an object of the Course class. o A Boolean method that returns true if the calling object has the same number of units of the parameter object, and false otherwise. Method printcourselnfo o Prints the course information in the following format: CS 170 (4 units)

Explanation / Answer

Class Course{

Private String courseDept;

Private int courseNo;

Private int courseUnits;

Public Course(String name, int courseNo)

{

     This.name=name;

   This.courseNo=courseNo;

}

Public String getCourseDept(){

Return courseDept;

}

Public void setCourseDept(String CourseDept){

This . CourseDept = CourseDept;

}

Public int getCourseNo(){

Return courseNo;

}

Public void setCourseNo(int CourseNo){

This . CourseNo=CourseNo;

}

Public int getCourseUnits(){

Return courseUnits;

}

Public void setCourseUnits(int CourseUnits){

This . CourseUnits=CourseUnits;

}

Public Boolean compareUnits(course c)

{

If(c==compareunits)

{

return true;

}

Else false;

printCourseInfo(){

System.out.println(“ courseDept:”+ courseDept);

System.out.println(“ courseNo:”+ courseNo);

System.out.println(“ courseUnits:”+ “(“courseUnits “)”);

}

//the program with three variables with same access modifier as private

and after the intialization and ovverride of the constructor

created the setters and getters for those variables

then of courseunits created a method which returns booleans variables als return types

finally printimng the output in the format we want