So, I’ve never really worked with JUnit

So, I’ve never really worked with JUnit

But, I have to make a JUnit test class for a “Course” Class that I have written in the past. the class should be named TestCourse.

Note: You do not need to test the void method (i.e., the printInfo method).

COURSE.JAVA

package activity3;

public class Course {

private String courseNo,title;
private int credit;

/**
* Constructor with a given courseNo and title. The default credit is 3.
* @param givenCourseNo The given courseNo
* @param givenTitle The given title
*/
public Course(String givenCourseNo, String givenTitle) {
courseNo = givenCourseNo;
title = givenTitle;
credit = 3;
}

/**
* Constructor with a given courseNo, title, and credit.
* @param givenCourseNo The given courseNo
* @param givenTitle The given title
* @param givenCredit The given credit
*/
public Course(String givenCourseNo, String givenTitle, int givenCredit) {
courseNo = givenCourseNo;
title = givenTitle;
credit = givenCredit;
}

/**
* Retrieve the courseNo of the course
* @return the courseNo of the course
*/
public String getCourseNo() {
return courseNo;
}

/**
* Retrieve the title of the course
* @return the title of the course
*/
public String getTitle() {
return title;
}

/**
* Retrieve the credit of the course
* @return the credit of the course
*/
public int getCredit() {
return credit;
}

/**
* Modify the title of the course
* @param newTitle The new title
*/
public void setTitle(String newTitle) {
title = newTitle;
}

/**
* Modify the credit of the course
* @param newCredit The new credit
*/
public void setCredit(int newCredit) {
credit = newCredit;
}

/**
* Return a string with the information of the course in the format of “courseNo – title (credit)”
* @return a string with the information of the course in the format of “courseNo – title (credit)”
*/
@Override
public String toString() {
String str;
str = courseNo + ” – ” + title + ” (” + credit + “)”;
return str;
}

/**
* Print the information of the course in the format of “courseNo – title”
*/
public void printInfo() {
System.out.println(courseNo + ” – ” + title);
}

}

Complete Answer:

Get Instant Help in Homework Asap
Get Instant Help in Homework Asap
Calculate your paper price
Pages (550 words)
Approximate price: -
Open chat
1
Hello 👋
Thank you for choosing our assignment help service!
How can I help you?