Click here to Skip to main content
15,886,519 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
addCourseName() – This method accepts a course code as a String.

subjectIllgibleToTeach-This returns a String with all the course codes an Instructor is certified to teach. The course codes should be separated by a comma but should not include [ ] at either end of the String. In other words, do not just return the ArrayList toString() method.


We have to pass the tests in both cases where tests are:

Java
public void testAddCourseName()
    {
        String courseCode = "COMP1011";
        instructor.addCourseName(courseCode);
        assertEquals(courseCode, instructor.subjectIllgibleToTeach());
    }


and

Java
public void testSubjectIllgibleToTeach()
    {
        String expResult = "COMP1011, COMP1008";
        instructor.addCourseName("COMP1011");
        instructor.addCourseName("COMP1008");
        String result = instructor.subjectIllgibleToTeach();
        assertEquals(expResult, result);
    }


We have to pass the certain tests and i have made a private arraylist of name courses above and passed string in it but still my test has been failing.

What I have tried:

Java
if(courseCode.isEmpty())
              throw new IllegalArgumentException("Course code cannot be empty.");
        else
        courses.add(courseCode);
Posted
Updated 11-Mar-18 11:57am
v2
Comments
wseng 12-Mar-18 3:42am    
please post the errors.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900