Question: I need some help coding this file. The Course class describes a course, including its name and maximum capacity. I have included the tests. Thank
I need some help coding this file. The Course class describes a course, including its name and maximum capacity. I have included the tests. Thank you!
package scheduler;
import java.util.List;
/**
* A class representing a Course.
*
* @author liberato
*
*/
public class Course {
/**
* Instantiates a new Course object. The course number must be non-empty, and the
* capacity must be greater than zero.
* @param courseNumber a course number, like "COMPSCI190D"
* @param capacity the maximum number of students that can be in the class
* @throws IllegalArgumentException thrown if the courseNumber or capacity are invalid
*/
public Course(String courseNumber, int capacity) throws IllegalArgumentException {
}
/**
*
* @return the capacity of the course
*/
public int getCapacity() {
return -1;
}
/**
*
* @return the course number
*/
public String getCourseNumber() {
return null;
}
/**
* Returns the list of students enrolled in the course.
*
* This returned object does not share state with the internal state of the Course.
*
* @return the list of students currently in the course
*/
public List
return null;
}
}
CourseTest.java
package scheduler;
import org.junit.Test;
import static org.junit.Assert.*;
import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.Timeout;
public class CourseTest { // uncomment the following if you're trying to diagnose an infinite loop in a test // @Rule // public Timeout globalTimeout = Timeout.seconds(10); // 10 seconds
private Course course; private String courseNumber; private int capacity; // This method is run before each test, performing initialization // on objects for the test. @Before public void setup() { courseNumber = "COMPSCI190D"; capacity = 120; course = new Course(courseNumber, capacity); } @Test public void testGetCourseNumber() { assertEquals(courseNumber, course.getCourseNumber()); }
@Test public void testGetCapacity() { assertEquals(capacity, course.getCapacity()); } @Test public void testGetRosterEmpty() { assertTrue(course.getRoster().isEmpty()); } @Test(expected = IllegalArgumentException.class) public void testInvalidCourseNumber() { Course c = new Course("", 20); }
@Test(expected = IllegalArgumentException.class) public void testInvalidCapacity() { Course c = new Course("COMPSCI190D", 0); } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
