make a class called SpecialTopicCourseTest class to test the SpecialTopicCourse class. Include the following components in this
Question:
make a class called SpecialTopicCourseTest class to test the SpecialTopicCourse class. Include the following components in this class:
- Create two objects of SpecialTopicCourse, c1 and c2, one using the 3-parameter constructor and the other one using the 4-parameter constructor. Both objects use SpecialTopicCourse as the data type.
- Creat e another object of SpecialTopicCourse, c3. The data type of c3 is Course instead of SpecialTopicCourse.
- Change the topic of one of the courses (using set method) and print the new topic using the get method.
- Print all the special topic courses using the overridden toString
- Print all the special topic courses using the overridden printInfo
- Test whether course c1 is equal to course c2 and whether course c1 is equal to course c3.
make a class called SpecialTopicCourse class which is a subclass of Course Include the following components in this class:
- It has a new variable called topic which describes the topic of the special topic course. Include get/set method for this variable.
- Include two constructors for SpecialTopicCourse class, a 3-parameter one (with given courseNo, title, and topic) and a 4-parameter one (with given courseNo, title, credit, and topic).
- Override the toString method to return the string in the following format: "courseNo - title (credit) (Topic: topic)", for example, "CSCI4905 - Special Topic in Computer Science (3) (Topic: Image Processing)".
- Override the printInfo method to print the course in the format of "courseNo - title (Topic: topic)". Credit is not included.
- Write the equals method which has one parameter of Object A special topic course is equal to another course if the other course is also a special topic course and they have the same courseNo and topic. Here is my code for Course
package activity4;
public class Course { private String courseNo,title; private int credit; public Course(String givenCourseNo, String givenTitle) { courseNo = givenCourseNo; title = givenTitle; credit = 3; } public Course(String givenCourseNo, String givenTitle, int givenCredit) { courseNo = givenCourseNo; title = givenTitle; credit = givenCredit; }
public String getCourseNo() { return courseNo; } public String getTitle() { return title; } public int getCredit() { return credit; } public void setTitle(String newTitle) { title = newTitle; } public void setCredit(int newCredit) { credit = newCredit; } @Override public String toString() { String str; str = courseNo + " - " + title + " (" + credit + ")"; return str; } public void printInfo() { System.out.println(courseNo + " - " + title); } }