Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Bellow is the course test if needed: package university.debug; import static org.junit.Assert.*; import org.junit.*; import university.*; import java.util.ArrayList; public class CourseTest { @Test public void
Bellow is the course test if needed:
package university.debug;
import static org.junit.Assert.*;
import org.junit.*;
import university.*;
import java.util.ArrayList;
public class CourseTest {
@Test
public void testStudent() {
Student s1 = new Student();
s1.setName("Tom");
assertEquals("Tom", s1.getName());
Department d = new Department();
s1.setDepartment(d);
assertEquals(d, s1.getDepartment());
Course course1 = new Course();
course1.setName("Java");
course1.setSchedule(201);
course1.setSchedule(401);
course1.setCourseNumber(373);
s1.addCourse(course1);
assertEquals("Tom", course1.getStudentRoster().get(0).getName());
}
@Test
public void testDepartment() {
Department d1 = new Department();
d1.setDepartmentName("ECE");
assertEquals("ECE", d1.getDepartmentName());
Course course1 = new Course();
course1.setName("OO Programming");
course1.setSchedule(201);
course1.setSchedule(401);
course1.setCourseNumber(373);
d1.addCourse(course1);
assertEquals("ECE", course1.getDepartment().getDepartmentName());
Student s1 = new Student();
s1.setName("Pattie");
d1.addStudent(s1);
assertTrue(s1.getDepartment().equals(d1));
assertEquals("Pattie", d1.getStudents().get(0).getName());
}
@Test
public void testStudentRoster() {
Student s1 = new Student();
s1.setName("Hagen");
Student s2 = new Student();
s2.setName("Daz");
Department d1 = new Department();
d1.setDepartmentName("ECE");
Course course1 = new Course();
course1.setName("OO Programming");
course1.setSchedule(201);
course1.setSchedule(401);
course1.setCourseNumber(373);
s1.addCourse(course1);
s2.addCourse(course1);
d1.addCourse(course1);
ArrayList sr = course1.getStudentRoster();
System.out.println(" Here is the Roster for " + course1.getName() + " course");
for (Student st : sr) {
System.out.println(st.getName() + " ");
}
System.out.println(" Here is the schedule for " + course1.getName() + " course");
ArrayList schedule = course1.getSchedule();
for (Integer time : schedule) {
System.out.println(time + " ");
}
System.out.println(" The department for " + course1.getName() +" course is "
+ course1.getDepartment().getDepartmentName());
}
@Test
public void testUniversity() {
University univ = new University();
Student s1 = new Student();
s1.setName("Hagen");
Student s2 = new Student();
s2.setName("Daz");
Department d1 = new Department();
d1.setDepartmentName("ECE");
Course course1 = new Course();
course1.setName("OO Programming");
course1.setSchedule(201);
course1.setSchedule(401);
course1.setCourseNumber(373);
s1.addCourse(course1);
s2.addCourse(course1);
d1.addCourse(course1);
d1.addStudent(s1);
d1.addStudent(s2);
univ.departmentList.add(d1);
/* Print department list from university */
System.out.println(" The list of departments in the university:");
univ.printDepartmentList();
/* Print student list from university */
System.out.println(" The list of students in the university:");
univ.printStudentList();
/* Print course list from university */
System.out.println(" The list of courses in the university:");
univ.printCourseList();
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started